Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by $$anonymous$$ · Mar 17, 2014 at 11:53 PM · collisionmovementphysicsrigidbodyplayer

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

alt text

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.

2) 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

little guy.png (278.0 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by DocMcShot · Mar 18, 2014 at 02:30 AM

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 :)

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image $$anonymous$$ · Mar 18, 2014 at 02:36 AM 0
Share

Thank you for your reply. I actually figured this out about 15-20 $$anonymous$$utes ago so the sticking problem doesn't occur anymore.

However, now I have sort of a different problem of everything being so slippery my character can slide right up certain things. In this image here, I've got a tiny cylinder. I think it might be because it's so small, but my character doesn't even have to jump on it, if you walk into it he just sort of climbs it. Same with the edge of the platform if you hit it from the right angle.

Obviously not bad for 4-6 hours of development on my first day so lol.

Also, I'm having a real problem with my jumps being too floaty. I have him being affected by a force I give to him, but he either jumps way to high or not at all, and if he does jump high enough gravity takes forever to get him back down. Is there anything I can do to help this?

alt text

little guy 3.png (128.6 kB)

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

20 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Collisions causing Rigidbody to go Haywire and move randomly. 1 Answer

A simple solution for constant rigidbody movement without changing and clamping velocity directly 2 Answers

Simple Movement Game: Physics vs Manual Collision Detection? 2 Answers

Vehicle Rigidbody Movement / Collision 1 Answer

Player getting stuck in ground (3D) player has Rigidbody, and Box Collider, world is Mesh Colliders 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges