Prevent sliding down slopes when using physics & gravity #2459
Unanswered
mattjennings
asked this question in
Q&A
Replies: 1 comment 5 replies
-
The first idea that came to my mind was also to disable gravity when grounded and if |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
How might I go about allowing an object to move up & down a slope without sliding down due to gravity? See this example:
https://codesandbox.io/s/excalibur-slopes-qgi0cz?file=/src/index.js
Try walking onto the slope with the arrow keys. Notice how the box slides down when you stop moving, and is also moving at different speeds when going up/down due to gravity.
I have tried increasing the friction on the body to a very high number but that didn't seem to affect anything. I also tried disabling gravity for the body when in contact with the ground, and while this works when walking up, walking down of course requires gravity being enabled again otherwise the object floats off of it.
At this point, I feel like disabling gravity when on the ground & finding a way to enable gravity when walking down the slope is my best option, but I'm curious if there are any other solutions.
Beta Was this translation helpful? Give feedback.
All reactions