Hello,
I’m aware of both Vector3.MoveTowards and Vector3.(S)Lerp, but I’m not sure how I could calculate their 3rd parameters to make the object moving finish in exact 3 seconds for example.
Any hints?
So what i want is:
Move transform from A to B in 5 seconds, speed doesnt matter, it only matters that it finished in the time given ( ± 0.5 seconds )
it does matter as it determines how long your object needs to travel the desired distance.
in init/start:
calc the difference of the positions b-a to get the vector the object need to move.
divide its length/magnitude by the time it should travel to get the required speed.
normalize the vector.
in update:
you multiply normalized vector * speed * time.deltatime and add this to the position of a.
See here (specifically the Translation function using MoveType.Time).
–Eric