angling character with terrain

Aug 25, 2009 at 9:15 PM
Edited Aug 25, 2009 at 9:27 PM

I've got a problem that I'm not sure how to go about solving. Below is 3 images i'll use as reference to describe what i'm trying to achieve. I would like to make my character follow the angle of the ground below it. in image one you see my character which contains 2 geoms and one body. The purple geom is the collision geom that keeps the character from falling through the ground and the green geom is my non-collision geom that detects if the character is on the ground or airborne (makes deciding which sprites to use more stable). when the character is moving left to right he is always upright. In image 2 shows what im trying to achieve. I'm trying to get the character to angle with the floor he's standing on. Now im not sure how to go about this but take note that the ground could be seperated into multiple geoms. Image 3 shows the complexity im hoping to achieve so that it appears as if the character is walking up a half pipe and angels acordinginly.

If you don't see the below image here is the link:



possible solution that i thought of but might not be very efficient is calculate the degree of every collision point on the green geom and use the medium.


please let me know if im being unclear about my question.. thank you.

Aug 25, 2009 at 11:07 PM

Again (like the other post I replied you), the solution is using rays. In my game I faced the same problem and solved it with the approach that Robertdodd suggested in his dev blog:

And works great :)

Aug 28, 2009 at 4:11 PM
Edited Aug 28, 2009 at 10:50 PM

in my other post you posted some code on how to find the body below you's linear velocity..


Is it possible you can also demonstrate how to find the ray distance from the character to the floor(nearest collision object bellow character)? maybe lead me to a link that has an example on how to use rays in this manner..