- Home /
Question by
Chieze · Nov 17, 2019 at 04:50 AM ·
2d-platformer2d physics
Prevent Velocity from being overriden
I'm working on a 2d plat former and I want to have a wall jump. The problem is that when you jump of the wall the force is immediately removed the next frame. how would i avoid that without having the movement speed buildup? Samples:
//add movement
moveVelocity.x = Input.GetAxis("Horizontal") * speed;
velocity.x = moveVelocity.x;
//velocity that is added when wall jumping
velocity.x += wallJumpHeight;
Comment
Answer by prof · Nov 17, 2019 at 07:12 PM
I'm not sure I understood the question, but if you're using Rigidbody for movement, then set force mode to impulse
AddForce(direction, ForceMode2D.Impulse);
Sidenote: Don't modify velocity on non-kinematic rigidbodies directly, unless you know what you're doing)