Controlling character with physics

I am trying to create a platformer in the style of sonic with slopes and loops etc. I know how to apply force to push the character along when on a flat surface, but how do I push from behind the character when running up a sloped surface or round a loop? applying the x force just pushes to the right still.

I think I need to apply detect which way the character is moving and apply the force from the opposite point, but don’t know how.

Thanks

Is the physics body for your character set up such that when it starts going “up a slope” it inherently wants to rotate to adjust? Meaning, does the character have some sort of physical “foot base” that makes the physics engine tilt the object as it starts moving up or down a slope? If so, you could inspect the rotation (.rotation) of the object and then use basic vector math to apply a force from the opposite side _depending o_n the rotation of the character.

Best regards,

Brent

Hi,

Thanks for the reply, at the moment it’s a circle for the body so it just rolls, but I was thinking I might need to change the shape if I’m going to use the rotation, I’ll give it a go.

Thanks

Is the physics body for your character set up such that when it starts going “up a slope” it inherently wants to rotate to adjust? Meaning, does the character have some sort of physical “foot base” that makes the physics engine tilt the object as it starts moving up or down a slope? If so, you could inspect the rotation (.rotation) of the object and then use basic vector math to apply a force from the opposite side _depending o_n the rotation of the character.

Best regards,

Brent

Hi,

Thanks for the reply, at the moment it’s a circle for the body so it just rolls, but I was thinking I might need to change the shape if I’m going to use the rotation, I’ll give it a go.

Thanks