I have used one polygon shape image (terrain)in my game its just like mountain and now i want to move the tanker on mountain path from one direction to other and then its turn on touching of the screne and move back and move like this continuously, i am not getting the method to move the tanker on slope(image) path in chipmunk spacemanager.

b.when collision detection happen like that if any bomb will fall on slope(image of mountain) then i want little damage on slope(image of mountain) like this video i want to please see this video for more details.


i have used this code but my object(tanker) is following terrain path with rotation i want to just move like tanker moving and follow terrain path.

    cpShape *localPlayerShape;
    cpCCSprite *localPlayerSprite;

    localPlayerShape = [mySpaceManager  addCircleAt:[self GetStartingWheelPosition] mass:2 radius:7];
    localPlayerSprite = [cpCCSprite spriteWithFile:@"enemy1.png"];





    [mySpriteLayer addChild:localPlayerSprite z:15];

Thank waiting for you all reply .


2 Answers 2


If you're trying to clone the game in the video, I wouldn't use real physics at all. Use a 1-dimensional height map for the ground -- that way you can just modify the data in the height map when a bomb hits the ground, rather than adding new vertices to a polygon.

When the tanks move, rotate them so that their treads are lined up with the slope of the ground and just move them horizontally, making sure that they're always at the same height as the ground underneath them. You can make them move slower or faster depending on the slope.

I think a physics engine is overkill for what you're trying to do. :)


If you need a quick hack to just set the position and angle of a body, use cpBodySetPos and cpBodySetAngle. Note that you're essentially not using the physics engine at all if you do that. :)

  • \$\begingroup\$ +1 I completely agree, for the example given, you only really need to know the height of the terrain at each pixel column, i.e. a 1D heightmap. Unless you need more complexity in your maps such as in Worms. \$\endgroup\$ Mar 1, 2012 at 5:18

To answer your first question: You need to apply a force or an impulse on your tank. You cannot directly "move" an object in chipmunk.

void cpBodyApplyForce(cpBody *body, const cpVect f, const cpVect r) 
void cpBodyApplyImpulse(cpBody *body, const cpVect j, const cpVect r)

To answer your second question: You need to deform your polygon shape according to the impact of the bomb. (I would stay away from this problem and concentrate on the first for starters.)


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .