Issues Making Character Move With Rigidbody

UPDATE
Okay I feel very dumb, I didn’t realize that the Rigidbody had a velocity parameter you could adjust:

rigidbody.velocity = new Vector3(Input.GetAxis("Horizontal") * Speed, rigidbody.velocity.y, Input.GetAxis("Vertical") * Speed);

So that solved my movement issue, but I am still having the wall sticking issue (where when you jump onto a wall, the character won’t fall until you press away from the wall). Any advice on that?

UPDATE 2: Electric Boogaloo It seems like Physics Materials helped my sticking issue. Now I have it to a point where everything is still sort of floaty but it works, and now that everything is basically frictionless… it makes it very easy to break the game in some areas. If there are any better ways to do this stuff, please I would still appreciate the input.

ORIGINAL

[23757-little+guy.png|23757]

Basically, I’m going for a sort of 2.5D platforming control scheme with flat characters (sort of like Paper Mario). I actually have this working (with rotations locked), but I have one of two different problems:

  1. Transform Method-

    transform.Translate(Input.GetAxis(“Horizontal”) * Speed * Time.deltaTime, 0, Input.GetAxis(“Vertical”) * Speed * Time.deltaTime, Space.Self);

This one actually works perfectly except, for the longest time, I couldn’t figure out why I couldn’t land next to a wall. I finally realized it’s because the rigidbody is physically trying to repel itself away from the wall collider, which makes sense.

  1. Force Method-

    rigidbody.AddForce/AddRelativeForce(Input.GetAxis(“Horizontal”) * Speed, 0, Input.GetAxis(“Vertical”) * Speed, ForceMode.???);

This one eliminates the wall bouncing problem however it creates several more. For one, I’m not completely sure which ForceMode I want? The main problem comes from the fact that a couple of them will either use it’s mass and take extremely high speeds to make it move (but then fly through the walls as soon as the character jumps because, you know, drag) or it will skip a step by not using mass and then just fly through a wall. Not to mention, this creates the problem of a very floaty character. The transform method isn’t perfect but it feels a lot more like an arcadey control scheme (which would be even better if I used GetAxisRaw()) but basically with the force methods it seems like the character will begin to move and I have no way to get him to stop until he basically feels like it.

Also, with both methods I seem to have issues sticking to the walls? Like if I hold the direction into the wall, it will continue to try moving until I let go, and THEN fall. I feel like this could be used for a good wall jumping mechanic, but unfortunately that’s not what I need.

Thank you for any help. :3

You need to add a “Material” to your collider. The material you add to the collider needs to have it’s friction set to 0. You can create a new material by going to “Assets” → “Create” → “Physics Material”. You’ll see other things that you can mess with within the material like bounciness. Just make sure your friction is set to 0 and you should be good to go.

Edit
Sorry, after you make the physics material prefab, be sure to drag it onto your collider or click the “Material” button on the collider and select the material you created.

Hope this helps


It wouldn’t let me answer your follow-up question in a new answer, so I’m posting the answers to your other questions below:

Are you sure the character is sliding up? Something I’ve ran into in the past with something similar to this is on the RigidBody component of your object. Set the collision detection to “Continuous” and see if that fixes the problem.

As far as the jumping seeming real floaty, you can change the gravity on your character by increasing the gravity scale on your RigidBody component. If you want to change the gravity of all objects in the game, you can click “Edit” → “Project Settings” → “Physics”, then change the Y value of gravity to a higher negative number (it’s default is -9.81), you might try something like -30 or something. Either of these options should make the jumping more snappy.

Just know that if you change the gravity a lot, you’ll have to apply a lot more force to get your character off the ground. If the character doesn’t jump, add like 500 force (or some other large amount)to it.

Hope this help :slight_smile: