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?
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.
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