The player controls a regular cube (which has a box collider and a rigid body) and all the walls in the level are also cubes (with box colliders). I’m using the arrow keys to move the player cube with the code below
input = new Vector3(Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical"));
if (rigidbody.velocity.magnitude < maxSpeed)
{
rigidbody.AddForce(input * moveSpeed);
}
What I’m finding is when the player jumps and hits a wall, it gets stuck in there a little bit and won’t move until I move the player away. I was thinking of hard coding the velocity when it hits the wall to maybe stop so it slides down it. Is there an easier way to fix this? Thank you!
I think the problem your having might be to do with friction. Change the physics material of the walls and it should drop down
I have a physics material on each wall with every friction setting set to 0. Just tried messing with some values and still getting the same result, just when I jump into the wall. Say I jump in from the right side because I’m going left and jump, it will stay stuck to the wall until I stop pressing the left arrow key.
well then I guess it’s because your applying a constant force even if it collides your setting its velocity. So either do a condition to make sure your not hitting the wall or like you said set the velocity when you collide
1 Like
Kinda have a fix now! I had had Bounciness of my material set to 0, as well. I put it to 1 and it ends up fixing the problem. Only problem now is it gets stuck when you’re pushing against the wall and jumping, but that can be coded using tags. Thanks for the help!