sidescroller-framework

Physics Component API

Physics component handles object physics.

Contents

Physics

Accessors

Physics.mass
Physics.width
Physics.height
Physics.bounciness
Physics.velocity
Physics.static
Physics.colliderType
Physics.friction

Physics:GetMass

Returns the mass of the Physics object

Example

local myMass = self.gameObject.physics:GetMass()

Physics:SetMass

Sets the mass of the Physics object to the given value

Arguments

Physics:GetWidth

Returns the width of the Physics object

Example

local myWidth = self.gameObject.physics:GetWidth()

Physics:SetWidth

Sets the width of the Physics object

Arguments

Physics:GetHeight

Returns the height of the Physics object

Example

local myHeight = self.gameObject.physics:GetHeight()

Physics:SetHeight

Sets the height of the Physics object

Arguments

Physics:GetBounciness

Returns the bounciness value of the Physics object

Example

local myBounciness = self.gameObject.physics:GetBounciness()

Physics:SetBounciness

Sets the bounciness of the Physics object to the given value

Arguments

Physics:GetVelocity

Returns the velocity vector of the object

Example

local myVelocity = self.gameObject.physics:GetVelocity()

Physics:SetVelocity

Sets the velocity of the Physics object to the given vector

Arguments

Physics:IsStatic

Returns whether or not the Physics object is static

Example

local isStatic = self.gameObject.physics:IsStatic()

Physics:SetStatic

Sets whether or not the Physics object is static

Arguments

Physics:GetColliderType

Returns the collider type of the object

Example

local myCollider = self.gameObject.physics:GetColliderType()

Physics:SetColliderType

Sets the collider type of the Physics object to the value

Arguments

Physics:GetFriction

Returns the friction coefficient of the object

Example

local myFrictionCoefficient = self.gameObject.physics:GetFriction()

Physics:SetFriction

Sets the friction coefficient of the Physics object to the given value. This should be a value between 0 and 1

Arguments

Physics:ApplyImpulse

Applies an impulse to the Physics object according to the given vector

Arguments