Answer the question
In order to leave comments, you need to log in
Unity2D How to implement jump from platform to platform?
There are two platforms (top and bottom). I'm trying to do it like this:
var jumpVector = new Vector2(0, jumpSpeed * jumpDirection * Time.deltaTime);
if (Input.GetKey(KeyCode.Space) && onGround)
{
characterRigidbody.AddForce(new Vector2(0, jumpForce * jumpDirection));
while (!onGround)
{
characterRigidbody.velocity = jumpVector;
}
jumpDirection *= -1;
characterRigidbody.gravityScale *= -1;
}
Answer the question
In order to leave comments, you need to log in
I don’t rummage for the unit, but I’ll give you a tip. If the object is on the platform, then when moving the platform, do += or -= (not =, because then the object will have the same coordinates with the platform, i.e. it will be inside it) of the coordinates of both the platform and the object.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question