Cafu Engine
ComponentPhysicsT Class Reference

This component includes the body of this entity in the dynamic simulation of physics. More...

Inheritance diagram for ComponentPhysicsT:

Public Member Functions

 ApplyImpulse (Vector3T Impulse)
 This method applies an impulse at the center of the entity's body. More...
 
 ApplyImpulse (Vector3T Impulse, Vector3T rel_pos)
 This method applies an off-center impulse to the entity's body. More...
 
 SetGravity (number gx, number gy, number gz)
 This method sets the gravity vector for this object, in m/s^2. More...
 
- Public Member Functions inherited from ComponentBaseT
any get (string var_name)
 Returns the value of an attribute (a member variable) of this class. More...
 
 set (string var_name, any new_value)
 Sets an attribute (a member variable) of this class to a new value. More...
 
string GetExtraMessage (string var_name)
 Returns the result of VarBaseT::GetExtraMessage() for the given member variable. More...
 
 interpolate (string var_name, number start_value, number end_value, number time)
 Schedules a value for interpolation between a start and end value over a given period of time. More...
 
EntityT GetEntity ()
 Returns the entity that this component is a part of (or nil if the component is currently "stand-alone", not a part of any entity). More...
 
 InitClientApprox (string VarName)
 Registers the given attribute (a member variable) of this class for interpolation over client frames in order to bridge the larger intervals between server frames. More...
 
 OnInit ()
 This method is called for each component of each entity as the last step of initializing a newly loaded map. More...
 
 OnClientFrame (number t)
 This method is called for each component of each entity before the client renders the next frame. More...
 

Public Attributes

number Mass
 The mass of the entity's body, in kilograms [kg]. More...
 

Detailed Description

This component includes the body of this entity in the dynamic simulation of physics.

Without this component, the entity is either static (it doesn't move at all), kinematic (it is moved by script or program code), or it doesn't participate in physics computations at all.

With this component, the entity's body is subject to gravity, impulses, and generally to the dynamic simulation of physics effects in the game world.

Note that the variables of this class (also referred to as "Public Attributes" or "Member Data") must be used with the get() and set() methods at this time – see get() and set() for details.

If you would like to create a new component of this type explicitly (those defined in the CaWE Map Editor are instantiated automatically), use WorldT::new():

local comp = world:new("ComponentPhysicsT")
Implementing C++ Class:
cf::GameSys::ComponentPhysicsT

Member Function Documentation

ApplyImpulse ( Vector3T  Impulse)

This method applies an impulse at the center of the entity's body.

The impulse is applied at the center of the body, so that it changes the body's linear velocity, but not its torque.

ApplyImpulse ( Vector3T  Impulse,
Vector3T  rel_pos 
)

This method applies an off-center impulse to the entity's body.

The impulse is applied at the center of the body, offset by rel_pos, changing the linear velocity and the body's torque appropriately.

SetGravity ( number  gx,
number  gy,
number  gz 
)

This method sets the gravity vector for this object, in m/s^2.

The default gravity vector is (0, 0, -9.81).

Member Data Documentation

number Mass

The mass of the entity's body, in kilograms [kg].

Related C++ type:
float