object.gravityScale

Type Number
Object Body
Library physics.*
Revision Release 2024.3703
Keywords body, gravityScale
See also physics.setGravity()

Overview

Use the gravityScale property to adjust the gravity on a single body. For example, setting it to 0 makes the body float (no gravity). The default value is 1.0 which means the body will behave under the normal simulated gravity.

Gotchas

Example

-- Create a rectangle
local myRect = display.newRect( 0, 0, 100, 100 )

-- Add a body to the rectangle
physics.addBody( myRect, "dynamic" )

-- Set gravity scale
myRect.gravityScale = 0.25