remove gravity from addBody object.

Hi my ‘helicopter object’ need to have a body to interact with enemy objects.
So i got:

 helicopterspriteSheet = sprite.newSpriteSheet("helicopters.png", 113, 55)  
 helicoptersprites = sprite.newSpriteSet(helicopterspriteSheet, 1, 4)  
 sprite.add(helicoptersprites, "helicopters", 1, 4, 1000, 0)  
 helicopter = sprite.newSprite(helicoptersprites)  
 helicopter.x = -80  
 helicopter.y = 350  
 helicopter:prepare("helicopters")  
 helicopter:play()  
 helicopter.collided = false  
 helicopter:setReferencePoint(display.CenterReferencePoint);  
 physics.addBody(helicopter, "static", {density=.1, bounce=0.1, friction=.2, radius=10})  
 screenGroup:insert(helicopter)  

But how can i stop gravity interfering with the helicopter, as it is controlled by the ‘Accelerometer’ but the gravity keep pulling it down.

maybe i can fix it by self:applyForce(0, -1.5, self.x, self.y) on tilt but how to do this ? [import]uid: 225288 topic_id: 36045 reply_id: 336045[/import]

Hi there,

There is actually a property called gravityScale which lets you set the gravity differently for each object. For your case, try [lua]helicopter.gravityScale = 0[/lua], which should make the helicopter immune to gravity.

Hope this helps!

  • Andrew [import]uid: 109711 topic_id: 36045 reply_id: 143184[/import]

it works thanks :smiley: [import]uid: 225288 topic_id: 36045 reply_id: 143187[/import]

Hi there,

There is actually a property called gravityScale which lets you set the gravity differently for each object. For your case, try [lua]helicopter.gravityScale = 0[/lua], which should make the helicopter immune to gravity.

Hope this helps!

  • Andrew [import]uid: 109711 topic_id: 36045 reply_id: 143184[/import]

it works thanks :smiley: [import]uid: 225288 topic_id: 36045 reply_id: 143187[/import]

Hi there,

There is actually a property called gravityScale which lets you set the gravity differently for each object. For your case, try [lua]helicopter.gravityScale = 0[/lua], which should make the helicopter immune to gravity.

Hope this helps!

  • Andrew [import]uid: 109711 topic_id: 36045 reply_id: 143184[/import]

it works thanks :smiley: [import]uid: 225288 topic_id: 36045 reply_id: 143187[/import]

Hi there,

There is actually a property called gravityScale which lets you set the gravity differently for each object. For your case, try [lua]helicopter.gravityScale = 0[/lua], which should make the helicopter immune to gravity.

Hope this helps!

  • Andrew [import]uid: 109711 topic_id: 36045 reply_id: 143184[/import]

it works thanks :smiley: [import]uid: 225288 topic_id: 36045 reply_id: 143187[/import]