# How to move the object(tanker ) on slope image in chipmunk Spacemanager

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.

-(void)AddWheel
{
cpShape *localPlayerShape;
cpCCSprite *localPlayerSprite;

localPlayerSprite = [cpCCSprite spriteWithFile:@"enemy1.png"];

localPlayerSprite.shape=localPlayerShape;

localPlayerSprite.shape->group=kItemIsPartOfTheTankGroup;
localPlayerSprite.shape->collision_type=kItemIsPartOfTheTankGroup;

localPlayerSprite.shape->u=4.5;

localPlayerSprite.tag=100;

}


Thank waiting for you all reply .

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. :)

Edit:

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. :)

• +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. – David Gouveia Mar 1 '12 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.)