A
A
Alexey Fobius2021-07-18 21:56:42
Unity
Alexey Fobius, 2021-07-18 21:56:42

How to move an object by several units?

I have a cube, the task is to move it exactly 5 units along the X axis when you press the key, just do it smoothly, through transform.Translate

I figured out the smooth movement, but how can I move it by a few units then?

I will say right away that MoveTowards will not work, the object always moves up along the Y axis (let's call it a runner) so moving between two points does not suit me

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
NoNameDeveloper, 2021-07-19
@phobious

transform.position = Vector3.Lerp(startPosition, endPosition, .1f);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question