Module KX_GameObject :: Class KX_GameObject
[frames | no frames]

Class KX_GameObject

Known Subclasses:
KX_Camera, KX_Light

All game objects are derived from this class.

Properties assigned to game objects are accessible as attributes of this class.
Method Summary
  applyImpulse(point, impulse)
Applies an impulse to the game object.
  disableRigidBody()
Disables rigid body physics for this object.
  enableRigidBody()
Enables rigid body physics for this object.
float getDistanceTo(other)
Returns the distance to another object or point.
list [vx, vy, vz] getLinearVelocity()
Gets the game object's linear velocity.
float getMass()
Gets the game object's mass.
KX_MeshProxy getMesh(mesh)
Gets the mesh object for this object.
3x3 rotation matrix getOrientation()
Gets the game object's orientation.
KX_GameObject getParent()
Gets this object's parent.
  getPhysicsId()
Returns the user data object associated with this game object's physics controller.
list [x, y, z] getPosition()
Gets the game object's position.
list [fx, fy, fz] getReactionForce()
Gets the game object's reaction force.
list [vx, vy, vz] getVelocity(point)
Gets the game object's velocity at the specified point.
  restoreDynamics()
Resumes physics for this object.
  setOrientation(orn)
Sets the game object's orientation.
  setPosition(pos)
Sets the game object's position.
  setVisible(visible)
Sets the game object's visible flag.
  suspendDynamics()
Suspends physics for this object.

Instance Variable Summary
float mass: The object's mass (provided the object has a physics controller).
string. name: The object's name.
3x3 Matrix [[float]] orientation: The object's orientation.
KX_GameObject parent: The object's parent object.
list [x, y, z] position: The object's position.
list [sx, sy, sz] scaling: The object's scaling factor.
boolean visible: visibility flag.

Method Details

applyImpulse(point, impulse)

Applies an impulse to the game object.

This will apply the specified impulse to the game object at the specified point. If point != getPosition(), applyImpulse will also change the object's angular momentum. Otherwise, only linear momentum will change.
Parameters:
point - the point to apply the impulse to (in world coordinates)
           (type=list [x, y, z])

disableRigidBody()

Disables rigid body physics for this object.

enableRigidBody()

Enables rigid body physics for this object.

Rigid body physics allows the object to roll on collisions.

getDistanceTo(other)

Returns the distance to another object or point.
Parameters:
other - a point or another KX_GameObject to measure the distance to.
           (type=KX_GameObject or list [x, y, z])
Returns:
float

getLinearVelocity()

Gets the game object's linear velocity.

This method returns the game object's velocity through it's centre of mass, ie no angular velocity component.

cf getVelocity()
Returns:
the object's linear velocity.
           (type=list [vx, vy, vz])

getMass()

Gets the game object's mass.
Returns:
the object's mass.
           (type=float)

getMesh(mesh)

Gets the mesh object for this object.
Parameters:
mesh - the mesh object to return (optional: default mesh = 0)
           (type=integer)
Returns:
the first mesh object associated with this game object, or None if this object has no meshs.
           (type=KX_MeshProxy)

getOrientation()

Gets the game object's orientation.
Returns:
The game object's rotation matrix
           (type=3x3 rotation matrix)

getParent()

Gets this object's parent.
Returns:
this object's parent object, or None if this object has no parent.
           (type=KX_GameObject)

getPhysicsId()

Returns the user data object associated with this game object's physics controller.

getPosition()

Gets the game object's position.
Returns:
the object's position in world coordinates.
           (type=list [x, y, z])

getReactionForce()

Gets the game object's reaction force.

The reaction force is the force applied to this object over the last simulation timestep. This also includes impulses, eg from collisions.
Returns:
the reaction force of this object.
           (type=list [fx, fy, fz])

getVelocity(point)

Gets the game object's velocity at the specified point.

Gets the game object's velocity at the specified point, including angular components.
Parameters:
point - the point to return the velocity for, in local coordinates. (optional: default = [0, 0, 0])
           (type=list [x, y, z])
Returns:
the velocity at the specified point.
           (type=list [vx, vy, vz])

restoreDynamics()

Resumes physics for this object.

setOrientation(orn)

Sets the game object's orientation.
Parameters:
orn - a rotation matrix specifying the new rotation.
           (type=3x3 rotation matrix, or Quaternion.)

setPosition(pos)

Sets the game object's position.
Parameters:
pos - the new position, in world coordinates.
           (type=[x, y, z])

setVisible(visible)

Sets the game object's visible flag.
Parameters:
visible
           (type=boolean)

suspendDynamics()

Suspends physics for this object.

Instance Variable Details

mass

The object's mass (provided the object has a physics controller). Read only.
Type:
float

name

The object's name.
Type:
string.

orientation

The object's orientation. 3x3 Matrix. You can also write a Quaternion or Euler vector.
Type:
3x3 Matrix [[float]]

parent

The object's parent object. (Read only)
Type:
KX_GameObject

position

The object's position.
Type:
list [x, y, z]

scaling

The object's scaling factor. list [sx, sy, sz]
Type:
list [sx, sy, sz]

visible

visibility flag.
Type:
boolean

Generated by Epydoc 2.1 on Thu Feb 1 00:12:33 2007 http://epydoc.sf.net