2D Game, Character Slides off Slopes, Need to be Able to Walk on Them

I have looked for about 6 hours now and haven’t found an answer to what I thought would be very simple. All I want to do is make it so that my character quits sliding off of anything not flat. He can walk up slopes that are slightly tilted but anything else is not walkable. I have looked at tutorials, looked at forums, videos, nothing has given me this answer.

Now, even though nothing has worked for me yet, from what I have found, it seems as if I will require a ray cast for this. I have tried using a ray cast to get the normal of the slope, but I don’t know how to turn that into a direction that can be applied to the character’s velocity, but I don’t know how to do that. Because wouldn’t I need to adjust the velocity to make the character’s movement match the rise of the slope?

So thanks in advance, any help is greatly appreciated. I am using C# and the latest version of Unity.


I figured it out, by reading something else completely unrelated! It was because I was using the wrong movement system. I was using AddForce for movement when I should have been using something other than physics based movement! I still have that for stuff like jumping for a more natural jump, but now I can walk up slopes.

I hope this helps anyone else with the same problem :slight_smile: