#How to let player not stick to ground when going uphill? (2D Platformer)

1 messages · Page 1 of 1 (latest)

weak crag
#

So I have shifted to avoid using physics forces and velocities and made my own custom code with the help of rb.MovePosition() . The player sticks to the ground on slopes, which is perfectly what I want, except when going uphill. I would want that if the player is fast enough, they should be able to fly off from the uphill slope. What would be the logic behind making that work? Here is a clip of what the movement looks like rn:

near heath
#

define going fast enough, and define fly off

#

like they keep moving in the direction forever off the cliff? into the sky?

weak crag
near heath
#

why not use the physics engine

weak crag
#

It applies velocity relative to the player rotation btw

near heath
#

that looks exactly like what you want

weak crag
#

It doesn't stick to the ground

#

It skips off the downhill slopes

weak crag
near heath
#

be more precise

still edge
#

You're honestly kinda confusing us on what you're trying to do. When do you want the player to stick to the ground and when do you want him to fly or shoot off?

#

Is the skateboard video an example of what you want, or an example of what you don't want?

#

It feels like you're telling us one thing, and then turning around and saying the opposite.

weak crag
#

Sorry I didn't mean to confuse. I want the skateboard example basically

#

So it should stick to the ground when the player goes downhill, and fly off when reaching the edge of an uphill.

near heath
#

should it be physically accurate

weak crag
#

well if the skateboard example is physically accurate then yes

near heath
#

okay use physics engine

still edge
# weak crag well if the skateboard example is physically accurate then yes

yeah so... If you want totally accurate physics, then you will want to use the physics system. Sticking to the ground is not something real skateboards do. Any thing that looks like it adhesion to the terrain is simply caused by two things: 1, the inertia of the board and rider, and 2, the centripetal force of the concave slope on the board.

weak crag
still edge
weak crag
#

but i already tried it and it didnt work as intended

still edge
#

I have to ask now: do you understand what these “forces” are?

weak crag
#

yes i know generally what they mean

#

so inertia is mass, centripetal force is mainly due to gravity

still edge
#

Wow! Very much no!

weak crag
#

oh

#

if u really want me to go detail and explain u that i undestand it, inertia is the fact that an object prefers to remain in its current state of motion, and the more mass, the more difficult it is to change that

still edge
#

ok yes that's right.

weak crag
#

but i prefer not going in detail and rather help me understand what im doing wrong

#

the code is a simple addforce, relative to player's transform.right, and using rigidbody's gravity

still edge
weak crag
#

sure, gimme a sec

#

the main 2 lines are 56 and 59, the rest is just a bunch of calculations