- Home /
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
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.
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.
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.
And I also want it to "glue" on some objects.. but I think thats another matter.
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.
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 :)
Yea but I think it's a good idea to use rigidbodies in my game, because it is kind of a physics game.
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.
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 ;)
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 :)
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.
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.
Your answer
Follow this Question
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