Predict next rigidbody position based on velocity

I’m making a 2D platform game and I’m moving the player applying a velocity on the rigidbody2D.
However, I have a situation where I need to be able to calculate the next “x” position of the rigidbody2D on the next frame in order do trigger something in the game.

Is there a way to calculate that based on the velocity?
I’m currently applying the velocity using the following code:

rigidbody2D.velocity = new Vector2(MOVE_SPEED * Time.deltaTime, rigidbody2D.velocity.y);

I’ve tried to calculate MOVE_SPEED * Time.DeltaTime and add it to the current x position of the player but It doesn’t work. The value is different from the actual next position.

Does anybody knows how can I do that?

Thank you!

hwww…

First - should your rigidbody move evenly, with constant speed? If so - you should not use deltaTime to calculate speed, just constants. Otherwise object could twitch some times. just like this

// to leave y-speed as it was:
rigidbody2D.velocity.y = MOVE_SPEED;

// or to make object move only to the right:
rigidbody2D.velocity = Vector2.right * MOVE_SPEED;

Second… distance = velocity x time, and point2 = point1 + path… so:

Vector2 predictedPoint = new Vector2(transform.position.x, transfomr.position.y) + rigidbody2D.velocity * Time.deltaTime;

but keep in mind that previous deltaTime could be not the same as next deltaTime if you use Update for calculations… so prediction could be not very accurate in this case…
if you use FixedUpdate instead - AFAIK you will have equal deltaTime for every call, and you will predict exatly right point.