# Tag Info

0

Looking at your comments, I think you want a smooth movement towards the target. To do that, your step is too small, since Time.deltaTime will usually be 0.01666 at 60 FPS. So your step will actually be very small and you will move little before you reset the position again. Instead, you can use this Coroutine instead of Vector3.MoveTowards: IEnumerator ...

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

0

If target is a transform, you want it to be target = pickedNumber.transform;, (no transform.position). If target is a Vector3, you want the next line to be ball.transform.position = Vector3.MoveTowards(transform.position, target, step);, (no target.position). I assume it's the first one, because of the wording of the error, but the second one is to show ...

0

There's a couple ways to do this. One way would be to store a dynamic number of previous positions instead of 100, and only throw old points away when the are beyond the length you want to show. A better way to do this though would probably be to store the last 100 evenly spaced positions where each position is totalDistance / 100 units apart. Basically, ...

0

There are a lot of ways to move something between two points. Want it to go in a straight line at a constant velocity? Then you might want to consider simple linear interpolation. // Gives you a value that linearly interpolates between the start and end. // t is an interpolation parameter between 0 and 1. When t = 0, the position is // at the stat. When t = ...

0

position += velocity * DeltaTime * speed; This is a better way of calculating the position. this way your movement wont slow down on framerate drops, because you take into account the time elapsed between the last Update call, if it was longer than usual (low fps) you move more distance. The code you have simply keeps increasing the position and never ...

Top 50 recent answers are included