I know this question has been asked before, and I’ve tried almost everything. My object is traveling around a cylinder and I would like for it to move over a certain amount of space on the press of an arrow key. The problem I’m having is that it just jumps over to the other position, when I would like for the change to be gradual and for the object to move more smoothly. I’m using transform. translate, but I’ve tried all the other solutions I’ve found on the internet ( transform. position = etc.)
Help is greatly appreciated, thanks. (Also, I’m not sure if it says but I’m using c#.)
Dude, you’ve forgotten to factor in time. If “brem” is your speed then it should be:
transform.Translate (Vector3.right * berm * Time.deltaTime);
Using a coroutine is no different in that matter than using it in Update.
Also, above code will still not work because in CoRo you need to make your own loop for this to move continuously. And you probably want to slerp the movement like here:
I would suggest not using coroutines, instead use Vector3.Lerp inside update loop. When you press a button, store the position of the object and Time.time in variables. Then, you also have time for the stuff to happen, for example 2.0, you can also store the value of it somewhere like float moveTime so it can be changed. Then target position is how much you want to move the object. So the lerp function should look like this: