P
P
piffo2020-05-30 00:18:11
Unity
piffo, 2020-05-30 00:18:11

Vector3.lerp on trigger entry?

It is necessary that when the player and the trigger collide, the following happens

came.transform.position = Vector3.Lerp(exod, pos0, progress);
progress += step;

came should smoothly move from the exod position to the pos0 position. Right now, it moves quite a bit each time it enters the trigger. How can this be fixed?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Denis Gaydak, 2020-05-30
@piffo

let's try to answer / describe in words HOW it should work for you. the points.
especially the moment that, in your opinion, the two lines indicated by you are doing.
and IMPORTANT all this, taking into account the moments "this is performed every frame", "and this is performed once during input / collision / at the start"
and most likely you will be able to understand why you "move quite a bit"
correct how? to do in the trigger - it is the flag/signal/event "must be moved", and the movement should be done like any other movement, not one-time / not in one frame.

T
TurnSpeedPotato, 2020-05-30
@TurnSpeedPotato

When the trigger fires bool lerCame = true?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question