Tag Info

New answers tagged

0

Simply set the object's Transform.position to Vector3.Lerp(Vector3 A, Vector3 B, percent completion


3

From the docs on transform.Translate: public void Translate(float x, float y, float z, Space relativeTo = Space.Self); If relativeTo is left out or set to Space.Self the movement is applied relative to the transform's local axes. (the x, y and z axes shown when selecting the object inside the Scene View.) So because you have not specified a ...


0

It seems like your transformations might be accumulating over time. As repeatedly "stepping forward" and "rotating around your axis" will cause the black bar to walk in circles. I'm unfamiliar with Unity, but there are some general approaches that might be applicable: You could try recalculating the object's position from its starting position, rather than ...


0

If you want to store a reference from the tile to the unit(s) occupying it, then just do it. As long as you remember to remove the reference whenever a unit leaves a tile (as you should do anyway, to mark the tile as unoccupied), the circular references will not affect the garbage collection of destroyed units in any way. The one situations where circular ...


0

I'm not entirely certain this will help with your physics problem, but I remember reading about two different types of force options when you use AddForce. One adds a ramping force and the other is an instantaneous impulse force. Might be worth reading into. :)


1

First go though your list of obstacles an compile a list of fields that are currently unavailable for movement. This list could contain field IDs or grid references or some other way to identify a field that works for your data structures. Next perform your Breadth-First Traversal and for each field perform a check to see if it is on the list of fields ...


1

It sounds like you already have a walk-map which says which tiles are walkable and which are non-walkable based on the terrain: the static walkmap. What you need is a second walkmap which tells you which tiles are non-walkable because of object presence: the dynamic walkmap. This map only needs to be recalculated when there is a change, so you can keep it ...


0

AFAIK the standard way of doing things in Unity is to assign a (non physical) Character Controller to your player. The character controller just sets the velocity of a body with some simple rules (exactly as you want). Collisions with physical objects are faked by treating the character as a kinematic object that can't be affected by forces. This can lead ...


0

I did some more reading. And did it this way. It finally works. public Vector3 position1 = new Vector3(0 ,0, 0); public Vector3 position2 = new Vector3(2, 2, 2); void Update(){ transform.position = Vector3.MoveTowards(transform.position, position2, 23 * Time.deltaTime); if ...


3

I'm assuming you're a beginner so I've kept this as simple as I could think of. Please let me know if you need more clarity. public class ObjectMover : MonoBehaviour { public Vector3 position1 = new Vector3(0.0f, 0.0f, 0.0f); public Vector3 position2 = new Vector3(2.0f, 2.0f, 2.0f); Vector3 currentTargetDestination; public float ...


2

The equations of motion for a differential drive machine are as follows, where x, y, θ, and l are the 2D position, orientation, and drive shaft length (distance between wheels) respectively: While a tank is not quite an ideal differential drive machine, this should be a sufficient approximation. Translating this into code using a simple Euler ...


1

Depending on your implementation and needs, this may not work for you, but one method is to use Unity Navmeshes. The way Navmeshes work is that you select the portions of the level which you want your runner to be able to move in and then bake them. This will then define where your runner can move. You will need to add a NavMesh Agent to your runner. The ...


1

If you end up having to roll your own, the common solution to having objects on paths (cameras moving over time, objects moving over time, cars driving in traffic lanes) is to use curves. Here's a gentle intro to 2d bezier curves I wrote that you can easily extend to 3d. http://blog.demofox.org/2014/03/04/bezier-curves/ ...


1

First of all, the method of just using the elapsed time since the last frame should absolutely work just fine in 99% of all cases. If you're having problems, there's probably a bug in your implementation. That said, this problem is generally referred to as numerical integration. Given a set of system dynamics (rules that define the next state of the system ...



Top 50 recent answers are included