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 nkr · Jul 25, 2011 at 02:45 PM · physicsrigidbodycharactercontrollergravityramp

Should my character controller slide down a ramp when I apply gravity to it?

Because that's what I currently want to achieve, but I don't want to use rigidbodies because I need to have more control over physics. My character controller is on a down ramp but it's not sliding down. Is there a way to do that without using rigidbody?

Thanks

Comment
Add comment · Show 6
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 Alec-Slayden · Jul 25, 2011 at 04:43 PM 0
Share

the character controller doesn't use real physics. In order to use real gravity, you'll have to make a rigidbody somewhere :/ I think you might have to choose between rigging a physical controller or rigging an artificial ramp slide. If its not going to be frequent, the ramp slide will likely be your best bet, since then you don't have to tweak the natural feel of the character movement.

avatar image nkr · Jul 25, 2011 at 05:02 PM 0
Share

I guess i'll have to use a rigidbody for it.. But I've gotta find a way to better control the effect of physics on my object.

avatar image Jason B · Jul 25, 2011 at 06:31 PM 0
Share

Controlling physics is still very possible even when using a Rigidbody. If all you want is for the rigidbody to not fall over, simply lock its rotation.

avatar image nkr · Jul 25, 2011 at 06:34 PM 0
Share

And I also want it to "glue" on some objects.. but I think thats another matter.

avatar image Jason B · Jul 25, 2011 at 06:36 PM 0
Share

Could also be done very simply. If you want the rigidbody to be stuck and not move, simply set its is$$anonymous$$inematic value to true and parent it to whatever it's stuck on. There's really nothing a CharacterController can do that a rigidbody can't do better in my experience. Feel free to ask more questions another time if you need help using a rigidbody.

Show more comments

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by testure · Jul 25, 2011 at 06:41 PM

I don't konw what the other guys who are commenting on your question are on about- you do NOT have to use rigid body simulations. In fact, unless you want your character to have physics applied all the time, it's pretty much a waste of time and processing power.

Adding slide velocity is just as easy as making a 'jump' work. All you have to do is apply downward velocity for gravity and forward velocity in the direction the slope would have you slide. It really is that simple... I'm not sure why so many things get overcomplicated.

For example- in super mario world, you could slide down hills. do you think they used physics simulations for that? I don't think so :)

Comment
Add comment · Show 5 · 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 nkr · Jul 25, 2011 at 06:45 PM 0
Share

Yea but I think it's a good idea to use rigidbodies in my game, because it is kind of a physics game.

avatar image Jason B · Jul 25, 2011 at 06:53 PM 0
Share

There's a lot more code involved with getting a CharacterController to work just the way you want it. Not to mention, CharacterControllers have a few show-stopping bugs attributed with them (especially when you want to make your character jump). The reason I recommend using a rigidbody is because it requires ten times less effort for an equal or better result. The processing power is absolutely negligible, especially if you've locked its rotation, your iterations are low, and if it's only the player character that is using one. Also, nowhere did I say you HAVE to use a rigidbody. I was making a suggestion based on my personal experience that working with rigidbodies is a lot less fuss and a lot more function than using a CharacterController.

avatar image testure · Jul 25, 2011 at 07:15 PM 0
Share

I respectfully disagree.. I find that 'tweaking' a character controller's behavior in a non-simulated environment is $$anonymous$$UCH easier than applying a rigid body and hoping the physics look correct. In games that I have worked on, we've done both- and 'faking' gravity/slide velocity has always been the more controllable way of doing things.

I mean- RB's look great out of the box- but what happens when they don't behave exactly as you want? You have to start screwing around with adding forces or tweaking friction/bounce. If you just want a generic physical slide and don't really care how it looks or behaves, then I concede that it is much easier to slap one on there and forget about it.

But, I'm getting away from what the OP is asking- and based on his comment it seems like he's making a physics game, which would negate my point entirely.

carry on ;)

avatar image nkr · Jul 25, 2011 at 07:18 PM 0
Share

Dont worry, Im glad to read such great posts...this subject is very confusing and it seems that most new unity users such as myself get confused about it :)

avatar image guavaman · Oct 24, 2013 at 01:02 AM 0
Share

you do NOT have to use rigid body simulations. In fact, unless you want your character to have physics applied all the time, it's pretty much a waste of time and processing power.

I know this is an old thread, but I just wanted to add to the discussion this fact: CharacterControllers are very much slower than rigidbodies. I had done some tests in the past and found that using CC's for units, the game would start getting slow with around 30 on screen. You could have many times more rigidbody units before it began to slow down.

avatar image
1

Answer by MichaelJT · Feb 28, 2018 at 03:05 PM

Here's how I would go about it.

First, use a raycast to get the ground normal. You get that from RaycastHit.normal.

Then compare the normal to Vector3.up. This will give you an angle.

If that angle is greater than the value you want to make your character slide at, then use Vector3.ProjectOnPlane to tell your character which way you want to move, then move your character along that plane.

Because Vector3.Angle doesn't tell you if the angle is positive or negative, use a CrossProduct to figure out the sign of your angle and move your character in the resultant direction.

Here's a vid with info about using CrossProduct.

link text

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

8 People are following this question.

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

Related Questions

FPS Character Controller with the push DOWN rigidbodies ability 0 Answers

Gravity not working 1 Answer

Guidelines for using rigidbody, collider, CharacterControllerScript, etc? 3 Answers

Movement on a tube 1 Answer

Rigidbody ball physics 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