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
1
Question by Shirogatsu · Nov 21, 2012 at 04:11 PM · rigidbodycharacter controllerslopeslopes

Rigidbody controller and slopes

Hello! I made a rigidbody player controller for anti-gravity jumps and stuff, that's why i can't use character controller. Everything was fine, but then i bumped into slopes problem. Is there any way to move "through" slopes gracefully with rigidbody? As i said, i can't use character controller for my project.

Comment
Add comment · Show 2
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 aldonaletto · Nov 21, 2012 at 11:30 PM 0
Share

Slopes or steps? Usually rigidbodies climb slopes, but get stuck at steps.

avatar image Shirogatsu · Nov 22, 2012 at 07:41 AM 0
Share

yeah, sorry, i mean steps!

1 Reply

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by aldonaletto · Nov 23, 2012 at 01:45 PM

I used a capsule collider with a rigidbody character, and it could climb steps up to half its height. My script is as follows:

 var horSpeed: float = 6.0;
 var jumpSpeed: float = 8.0;
 
 function Start(){
     // no physics rotations, please!
     rigidbody.freezeRotation = true;
 }
 
 function Update(){
     // get the direction it must walk in:
     var speed = Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")).normalized;
     // convert from local to world space and multiply by horizontal speed:
     speed = horSpeed * transform.TransformDirection(speed);
     // keep rigidbody vertical velocity to preserve gravity action:
     speed.y = rigidbody.velocity.y;
     // set new rigidbody velocity:
     rigidbody.velocity = speed;
 }

This is a basic movement script, and emulates the CharacterController behaviour - maybe it works as a starting point in your case. This script only moves forth/back and sideways - you can add a MouseLook script to the character with Axes = Mouse X to rotate it with the mouse, and another MouseLook to the camera (if it's a first person game) with Axes = Mouse Y to look up and down.
But I made once a simple "Gravity Guy"-like script using a CharacterController: it works in flipped gravity as well because the CharacterController is always vertical, even if we rotate the transform - the only problem is the property isGrounded, which will always be false when upside down.
If you want to walk on any surface instead - floor, ceil, walls etc. - use this script.

Comment
Add comment · 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

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

11 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

Related Questions

How to detect ground slope angles in 3d? 1 Answer

CharacterController Hops along upward slopes 1 Answer

Slope Limit on Rigidbody First Person Controller 1 Answer

Character pushes a cart. How to prevent cart from clipping? 0 Answers

climbing the hill? 1 Answer


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