Tag Info

Hot answers tagged

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 ...


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

If my assumption that you want your speed to lose 2% of its value every second, then this is a perfect opportunity to use the exponential rate of decay expression, which looks like this: A=Pe^(rt) A is the final amount you want (so, after 1 second, .98(vx)) and P is the initial amount. t is just time, so since you want the velocity to only be 98% of its ...


1

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


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 ...


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 ...



Only top voted, non community-wiki answers of a minimum length are eligible