Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 SirMacJefferson · Sep 16, 2011 at 05:43 AM · collisionphysicsrigidbodyterrain

Player's Rigidbody slides up terrain walls

My player has a rigidbody and a box collider. For some reason, he seems to slide up terrain walls. I move him via Translation, with a movement speed of at least 17 units per second (if that helps). It only takes three or four seconds to slide all of the way up a wall that's like, 6x as tall as my player...

As far as I know, I haven't done anything to the terrain's physics..whatever it has that determines stuff like that. I tried different physic materials, including a custom one with all values set to 0...but nothing got much different results. Also, I reset the rigidbody of the player and nothing different happened (all that had been different was his mass I think, probably when I was trying to figure out a way around this).

Another note, the terrain has been smoothed, but it's still quite steep.

Any help with getting it to not slide up terrain would be greatly appreciated!

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
2
Best Answer

Answer by syclamoth · Sep 16, 2011 at 06:40 AM

Well, Translation isn't really subject to physics- your character will do their best to move forward, and since Terrain objects (which I assume is what you mean by terrain) can never be perfectly vertical, that means sliding straight up! Have a look at using rigidbody physics instead, if you don't want your character doing strange stuff when interacting with other colliders.

Comment
Add comment · Show 4 · 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 SirMacJefferson · Sep 16, 2011 at 08:25 AM 0
Share

Thanks. I thought of trying rigidbody.AddForce() ins$$anonymous$$d of transform.Translate, but I'm not sure how the function works. Does it add the force and leave it there every time the function is called, or is it like Translate and has to be called continuously to keep the momentum going?

avatar image syclamoth · Sep 16, 2011 at 08:37 AM 0
Share

Rigidbody.AddForce makes one push on your rigidbody- it does not persist longer than one frame. However, it should be noted that since it adds a force ins$$anonymous$$d of just changing an object's position, the object in question will continue to move as long as there is no friction or other force acting on it to slow it down! Implementing objects that move at a constant speed and stop and start instantly is a little difficult to do with rigidbodies, because it is a behaviour that doesn't reflect reality very well. The most realistic way to stop an object from moving too fast, is to set its drag to something reasonably high, and then calling Rigidbody.AddForce every FixedUpdate- this results in an object accelerating until the drag forces perfectly cancel out the incident force, and the object remains at a constant velocity.

EDIT: Which is to say, no, you don't need to call it every frame to "keep the momentum going", but that probably isn't what you want, anyway.

avatar image SirMacJefferson · Sep 17, 2011 at 04:56 AM 0
Share

I see..I suppose I should start using rigidbody.AddForce ins$$anonymous$$d. I tried it out, but I'm going to have to rework my formulas a bit. Using the same Transform.Translate formula as I had but with "* Time.deltaTime" taken out, my jump script moved about half the distance it usually would have. The formula I'd been using was:

(JumpHeight / JumpTime) * Time.deltaTime

If you have any suggestions on how to get the rigidbody to smoothly move you the distance provided per second, that would be great. Thanks for all the help you've been, also! :)

EDIT: $$anonymous$$aybe some way of figuring out how long it takes to start moving at the given speed (the build-up time) or something like that...

avatar image syclamoth · Sep 18, 2011 at 05:01 AM 0
Share

Well, the way I do it is to have a 'desired speed', and then reduce the amount of force depending on how close to it you are moving. As for the Time.deltaTime thing, you should always always ALWAYS have it in there, otherwise all your physics stop being frame-rate independent!

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Terrain collider failing in unity 5/17? 1 Answer

Innacurate terrain collision with fast rigidbody 1 Answer

Object Flies into Air Upon Collision, or goes through hill depending on isKinematic settings 1 Answer

Keep Horizontal Momentum after Jump 2 Answers

Collision.impulse = 0 in OnCollisionStay Kinematic Static collision pair after Update 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