Cafu Engine
ComponentPlayerPhysicsT Class Reference

This component implements human player physics for its entity. More...

Inheritance diagram for ComponentPlayerPhysicsT:

Public Member Functions

 MoveHuman (number FrameTime, Vector3T WishVelocity, Vector3T WishVelLadder, bool WishJump)
 This is the main method of this component: It advances the entity's origin according to the laws of simple physics and the given state and parameters. 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

tuple Velocity
 The current velocity of the entity. More...
 
tuple Dimensions
 The bounding box of the entity (relative to the origin). More...
 
number StepHeight
 The maximum height that the entity can climb in one step. More...
 
boolean OldWishJump
 Only jump if the jump key was not pressed in the previous frame. More...
 

Detailed Description

This component implements human player physics for its entity.

It updates the entity's origin according to the laws of simple physics that are appropriate for player movement. The component does not act on its own in a server's Think() step, but is only a helper to other C++ or script code that must drive it explicitly.

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("ComponentPlayerPhysicsT")
Implementing C++ Class:
cf::GameSys::ComponentPlayerPhysicsT

Member Function Documentation

MoveHuman ( number  FrameTime,
Vector3T  WishVelocity,
Vector3T  WishVelLadder,
bool  WishJump 
)

This is the main method of this component: It advances the entity's origin according to the laws of simple physics and the given state and parameters.

Other C++ or script code of the entity typically calls this method on each clock-tick (frame) of the server.

Parameters
FrameTimeThe time across which the entity is to be advanced.
WishVelocityThe desired velocity of the entity as per user input.
WishVelLadderThe desired velocity on a ladder as per user input.
WishJumpDoes the user want the entity to jump?

Member Data Documentation

tuple Dimensions

The bounding box of the entity (relative to the origin).

Related C++ type:
BoundingBox3dT
boolean OldWishJump

Only jump if the jump key was not pressed in the previous frame.

Related C++ type:
bool
number StepHeight

The maximum height that the entity can climb in one step.

Related C++ type:
double
tuple Velocity

The current velocity of the entity.

Related C++ type:
Vector3dT