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 formidable · May 12, 2012 at 08:17 PM · rigidbodyslerpslopesliding

Problem sliding down hills (WITH VIDEO)

Hello,

I can't get my character to slide down a hill properly, sort of like a skier/snowboarder. I'd really like to know why my character falls where the red arrow is. He also fell when I tried to use multiple planes in unity to simulate a slope. As soon as he got on a different plane he would die.

Here's a gif of what happens right now. As soon as he hit the new normal he just dies...

![alt text][1] [1]: http://answers.unity3d.com/storage/temp/897-slope_fail.gif

var isGrounded: boolean = false; var hit: RaycastHit; var theRay: Vector3; var currentPos : Transform;

function FixedUpdate () { if(isGrounded) { theRay = transform.TransformDirection(Vector3.down); // Convert from local space to world space

     if (Physics.Raycast(transform.position, theRay, hit))
     {
        transform.rotation = Quaternion.FromToRotation(Vector3.up, hit.normal);
     }
 }
 Debug.Log(isGrounded);
 Debug.DrawRay(transform.position, theRay, Color.red);

}

function OnCollisionEnter(collision : Collision) { isGrounded = true; }

function OnCollisionExit(collisionInfo : Collision) { isGrounded = false; }

slope_fail.gif (492.7 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
Best Answer

Answer by formidable · May 13, 2012 at 03:12 AM

Fuck yeah I think I got it! The problem is my character would touch the next normal, get its position and leave the ground just enough to start spiraling out of control. I fixed it by zeroing the characters angular velocity as soon as it leaves the ground. I just had to add this little bit of code

function OnCollisionExit(collisionInfo : Collision)
{
    isGrounded = false;
    // Prevent character from spiraling out of control the second it goes airborn
    rigidbody.angularVelocity = Vector3.zero; 
}

I still have a lot to do like smoothing out the transition between normals and making the character only able to go forward or backward but that can wait. I've been trying to figure this out for 2 weeks!

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 formidable · May 13, 2012 at 03:36 AM 0
Share

I almost forgot. You also have to give the ground a physics material and set the friction combine to $$anonymous$$inimum, dynamic friction, static friction and bounciness to 0. No vlue what the friction combined does but it gets rid of the jittery effect when the character is sliding down

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Increasing dynamic friction 1 Answer

Making objects slide 1 Answer

Help with sliding down hills 1 Answer

Rigidbody slides across surface 0 Answers

Rigidbody problem 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