Skip to main content
edited title
Link
user1430
user1430

How tocan I make a character stand on slopes?

Tweeted twitter.com/#!/StackGameDev/status/480617895991705600
Source Link
Pop Flamingo
  • 513
  • 1
  • 4
  • 7

How to make a character stand on slopes

First of all, note that I want to understand the principle, so I would prefer explanations in plain english (but of course I have nothing against some code to complement these explanations).

I am wondering what is the way to make a character step correctly on a slope, let's start with two screenshots of the game Limbo to show you what I mean : Limbo principal character standing on a slope Limbo principal character standing on a flat ground
So, as you can see on these pictures, it looks like the spine of the character is actually perpendicular to the horizon and not to the surface of the ground and this observation leads me to my question:
How can you reproduce such a behavior with Sprite Kit ? Because if I attach a physic body to a node, I have the possibility to let it rotate, so I would get something like this : We can see that the sprite follows the ground on which it stands, so the feet of the character are on the floor but its spine isn't perpendicular to the horizon but more to the ground

If I disable the rotation I would get something more like this : Here the spine is perpendicular to the horizon but the feet of the character doesn't touch the floor. In fact there is only a corner of the sprite that touches the floor
As you can see these ways to do both present important issues and doesn't looks natural at all. So how should I do to make it look natural ? I thought to create several sprites and several physics bodies and then attaching them all together with joints I don't think that it will look natural because if you look at this : enter image description here
Although I can physically link these nodes, how will I do to make them look real graphically ? Because in the reality, for example, the thigh and calf are linked by a knee...

Any ideas ?