new PhysicComponent(pWidth, pHeight, pOwner)
Parent component of physics components to add to a game object for collisions
and physics behavior.
Parameters:
Name | Type | Description |
---|---|---|
pWidth |
int | Width of the collider. |
pHeight |
int | Height of the collider. |
pOwner |
FM.GameObject | The object that owns this component. |
Extends
Members
-
acceleration :FM.Vector
-
Acceleration applied to the physic object.
Type:
-
angularDrag :FM.Vector
-
How much the object's velocity is decreasing when acceleration is equal to 0.
Type:
-
angularVelocity :int
-
Angular velocity.
Type:
- int
-
drag :FM.Vector
-
How much the object's velocity is decreasing when acceleration is equal to 0.
Type:
-
elasticity :float
-
Elasticity is a factor between 0 and 1 used for bouncing purposes.
Type:
- float
-
height :int
-
Height of the collider.
Type:
- int
-
maxAngularVelocity :int
-
Maximum angular velocity.
Type:
- int
-
maxVelocity :FM.Vector
-
Represent the maximum absolute value of the velocity.
Type:
-
name :FM.ComponentTypes
-
Component's name.
Type:
- Inherited From:
- Source:
-
offset :FM.Vector
-
Offset of the bounding box or circle.
Type:
-
owner :FM.GameObject
-
Component's owner.
Type:
- Inherited From:
- Source:
-
velocity :FM.Vector
-
Velocity of the physic component.
Type:
-
width :int
-
Width of the collider.
Type:
- int
Methods
-
addCollision(pCollision)
-
Add a collision object representing the collision to the list of current collisions.
Parameters:
Name Type Description pCollision
FM.Collision The collision object to add. -
addTypeToCollideWith(pType)
-
Ensure that a game object collides with a certain type of other game objects (with physic components of course).
Parameters:
Name Type Description pType
FM.ObjectType The type to add to the list of types that this object can collide with. -
destroy()
-
Destroy the component and its objects.
-
getInvMass() → {int}
-
Retrieve the inverse mass of the physic object.
Returns:
The inverse mass of this object.- Type
- int
-
getLinearVelocity() → {FM.Vector}
-
Get the velocity.
Returns:
The vector containing the current velocity of the object.- Type
- FM.Vector
-
getMass() → {int}
-
Retrieve the mass of the physic object.
Returns:
The mass of this object.- Type
- int
-
isCollidingWith(pOtherGameObject) → {boolean}
-
Check if the current physic component is colliding with another one.
Parameters:
Name Type Description pOtherGameObject
FM.GameObject The game object to test for collision with this one. Returns:
Whether there is already collision between the physic components.- Type
- boolean
-
isCollidingWithType(pOtherType) → {boolean}
-
Check if the current physic component is colliding a specified type of physic component.
Parameters:
Name Type Description pOtherType
FM.ObjectType The type of objects to test for collision with this one. Returns:
Whether there is already collision between the the current physic component and the specified type of physic component.- Type
- boolean
-
removeTypeToCollideWith(pType)
-
Remove a type that was supposed to collide with this game object.
Parameters:
Name Type Description pType
FM.ObjectType The type to remove from the list of types that this object can collide with. -
resolveCollision(pOtherPhysic, pCollision)
-
Resolve collision between current game object and the specified one.
Parameters:
Name Type Description pOtherPhysic
FM.PhysicComponent The other physic component of the collision. pCollision
FM.Collision The collision object containing the data about the collision to resolve. -
setMass(pNewMass)
-
Set the mass of the physic object.
Parameters:
Name Type Description pNewMass
int The new mass to set. -
update(dt)
-
Update the component.
Parameters:
Name Type Description dt
float The fixed delta time since the last frame.