- Home /
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.
:)
Answer by JTrocks55 · Oct 19, 2016 at 02:12 PM
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 :)
Your answer
Follow this Question
Related Questions
InvalidCastException: Cannot convert from source type to destination type using a Rigidbody2D 2 Answers
Restrict a Players Movement Up a Slope 1 Answer
Make characters go through each other 1 Answer
[Solved] Rigidbody2d smooth movement 1 Answer
Child GameObject can't use MovePosition on parent's Rigidbody2D? 3 Answers