Sticking to a wall
Posted: Sun Nov 03, 2013 3:30 pm
Hello,
I am new to the chipmunk and its forum. I am working on a game where the main hero is a ball and can move on terrain which is made out of segment shapes. The ball is moved by setting its angular velocity (so you can't throw it in the air). Now i would like to enable that the ball can stick to the terrain and when you move it, it should follow the terrain outline. So for instance if you have a cliff and you move the ball of the cliff it wouldn't fall off but move along the vertical edge or if you have a wall it should climb up a wall.
What i would like to archive is that if you move it of a cliff it should move in the same way as it would on flat ground. What would be the simplest way to do this? My idea was to change the gravity vector when colliding with the segment in the direction of the segment, but the problem is that when moving of a cliff it would fall off since my collision handler gets called only when colliding with the horizontal segment and not the wall segment (the cliff is made out of two segments a horizontal one and a vertical one that makes the wall). And i cannot offset the segments since they are created dynamically. Is there any other way of doing this, perhaps with a constraint?
Thanks!
I am new to the chipmunk and its forum. I am working on a game where the main hero is a ball and can move on terrain which is made out of segment shapes. The ball is moved by setting its angular velocity (so you can't throw it in the air). Now i would like to enable that the ball can stick to the terrain and when you move it, it should follow the terrain outline. So for instance if you have a cliff and you move the ball of the cliff it wouldn't fall off but move along the vertical edge or if you have a wall it should climb up a wall.
What i would like to archive is that if you move it of a cliff it should move in the same way as it would on flat ground. What would be the simplest way to do this? My idea was to change the gravity vector when colliding with the segment in the direction of the segment, but the problem is that when moving of a cliff it would fall off since my collision handler gets called only when colliding with the horizontal segment and not the wall segment (the cliff is made out of two segments a horizontal one and a vertical one that makes the wall). And i cannot offset the segments since they are created dynamically. Is there any other way of doing this, perhaps with a constraint?
Thanks!