GameObject

Basic unit of a scene.  Everything in the world is represented by a GameObject.  A GameObject’s exact behavior is defined by the types of components that are attached.

Summary
GameObjectBasic unit of a scene.
Component
NKGetAnimatedGraphicsGet the AnimatedGraphicsComponent attached to this GameObject.
NKGetMorphGraphicsGet the MorphGraphicsComponent attached to this GameObject.
NKGetPlaceableMaterialGet the PlaceableMaterialComponent attached to this GameObject.
NKGetPlaceableGet the PlaceableComponent attached to this GameObject.
NKGetEquipableGet the EquipableComponent attached to this GameObject.
NKGetPhysicsGet the PhysicsComponent attached to this GameObject.
NKGetTransformGet the TransformComponent attached to this GameObject.
NKGetLightGet the LightComponent attached to this GameObject.
NKGetSoundGet the SoundComponent attached to this GameObject.
NKGetNetGet the NetComponent attached to this GameObject.
NKGetCharacterControllerGet the CharacterController attached to this GameObject.
NKSetEmitterActiveSets the emitter component for this object and all of its children to the given activity state.
NKActivateEmitterByNameActivates a specific child emitter on this object.
NKDeactivateEmitterByNameDeactivates a specific child emitter on this object.
NKSetControllerSets a character controller to manage this object.
NKGetBoundsRetrieves bounding data for the graphics component.
NKGetAttachPositionRetrieves the current position of a specified attach point (a sub-mesh suffixed with _atch) from the graphics component.
NKGetAttachPointReturns a specified attachment point of a game object’s GraphicsComponent
NKGetAttachmentOrientationReturns a quaternion representing the rotation produced for attaching an object to this object at specific attach points.
NKIsPhysicsDynamicReturns whether or not the physics component is set to be dynamic or static.
Scene
NKSetShouldRenderSets the visibility state of this GameObject.
NKShouldRenderReturns whether or not this object is set to render.
NKPlaceInWorldAdd this GameObject to the visible world and physics simulation.
NKRemoveFromWorldRemove this GameObject from the visible world and physics simulation.
Transform
NKGetScaleReturns the parent relative scale of this object.
NKGetWorldScaleReturns the world space scale of this object.
NKScaleSet the scale of this object.
NKGetPositionReturns the parent relative position of this object.
NKGetWorldPositionReturns the world space position of this object.
NKSetPositionSet the position of this object in the world.
NKGetOrientationReturns the parent relative orientation of this object.
NKGetWorldOrientationReturns the world space orientation of this object.
NKSetOrientationSet the orientation of this object in the world.
NKSetAbsoluteScaleSets the scale of this object such that it will appear at the size of the given scale, regardless of what its parent’s scale may be.
Hierarchy
NKAddChildObjectAdd a child object to this GameObject.
NKAddChildAtAttachPointAdds a child object to this object and attaches it to an attach point specified in the mesh.
NKRemoveChildObjectRemove a child object to this GameObject.
NKGetNumChildrenReturns the number of attached child GameObjects.
NKGetParentReturns the parent GameObject of this object.
NKGetMaxStackCountReturns the maximum stack count for a game object
NKSetGraphicsSet the graphics component on this object
NKGetGraphicsGet the base graphics component of this object
NKGetStaticGraphicsGet the StaticGraphicsComponent attached to this GameObject.
NKSetParentSets the parent of this GameObject to another.
NKIsInWorldReturns if the object has been placed in the world
NKGetChildrenReturns a table containing all of this object’s children objects.
Utility
NKGetNameReturns the type name of this GameObject.
NKGetInstanceThis function is deprecated and scheduled for removal.
NKDeleteMeDestroys this object at the end of the frame.
NKSetAttachBoneSets the bone this GameObject will attempt to follow in its parent object.
NKClearAttachBoneClears the bone attachment.
NKGetDisplayNameRetrieves the display name for this object, that is, the name that will appear in its name plate.
NKGetStackCountRetrieves the current stack count for this object.
NKSetStackCountSets the stack count for this item to the specified value.
NKModifyStackCountModifies this object’s stack count.
NKSetMaxStackCountSets the max stack count for an object, overriding its settings from its data file.
NKSetShouldSaveTells this object whether or not it should allow saving.
NKSetControllerCapsuleSizeSets the size of this object’s controller’s capsule.
NKGetWorldPlayerGets the world player of this object if there is one
NKEnableScriptProcessingEnable the script’s update function every frame or with an optional tick rate in milliseconds.
NKGetNetIdReturn the network ID of this object
NKRaiseScriptEventSend a network event between server and clients
NKSetShouldSaveChildren
NKRegisterScriptEventInternal function, creates new event type.
NKAddEmitterNameAdds emitter name to an attractor
NKLinkAttractorToEmittersLinks all emitters to attractors.
NKIsDistanceCulledReturns whether or not the engine has culled this game object due to it’s distance away from the player based upon the object’s radius and the player’s view distance
NKGetRootParentReturns the root parent GameObject of this object’s hierarchy.
NKSetWorldOrientationSets the gameobject’s orientation in world space.

Component

NKGetAnimatedGraphics

Get the AnimatedGraphicsComponent attached to this GameObject.

Returns

AnimatedGraphicsComponentThe AnimatedGraphicsComponent attached to this object, or nil if one is not attached.

NKGetMorphGraphics

Get the MorphGraphicsComponent attached to this GameObject.

Returns

MorphGraphicsComponentThe MorphGraphicsComponent attached to this object, or nil if one is not attached.

NKGetPlaceableMaterial

Get the PlaceableMaterialComponent attached to this GameObject.

Returns

PlaceableMaterialComponentThe PlaceableMaterialComponent attached to this object, or nil if one is not attached.

NKGetPlaceable

Get the PlaceableComponent attached to this GameObject.

Returns

PlaceableComponentThe PlaceableComponent attached to this object, or nil if one is not attached.

NKGetEquipable

Get the EquipableComponent attached to this GameObject.

Returns

EquipableComponentThe EquipableComponent attached to this object, or nil if one is not attached.

NKGetPhysics

Get the PhysicsComponent attached to this GameObject.  Holds the RigidbodyElement, ColliderElements and ControllerElement.

Returns

PhysicsComponentnil if there is no physics.

NKGetTransform

Get the TransformComponent attached to this GameObject.  Contains advanced functionality.

Returns

TransformComponentThe TransformComponent, by default all GameObjects have a TransformComponent.

NKGetLight

Get the LightComponent attached to this GameObject.

Returns

LightComponentThe LightComponent attached to this object, or nil if one is not attached.

NKGetSound

Get the SoundComponent attached to this GameObject.

Returns

SoundComponentThe SoundComponent attached to this object, or nil if one is not attached.

NKGetNet

Get the NetComponent attached to this GameObject.

Returns

NetComponentThe SoundComponent attached to this object, or nil if one is not attached.

NKGetCharacterController

Get the CharacterController attached to this GameObject.

Returns

CharacterControllerThe CharacterController attached to this object, or nil if one is not attached.

NKSetEmitterActive

Sets the emitter component for this object and all of its children to the given activity state.

Parameters

boolTrue to turn emitters on, false to turn them off.

NKActivateEmitterByName

Activates a specific child emitter on this object.  Note that this is not this object’s emitter component, but one of its children’s emitter components that matches the given name.

Parameters

stringThe name of the emitter to be activated.

NKDeactivateEmitterByName

Deactivates a specific child emitter on this object.  Note that this is not this object’s emitter component, but one of its children’s emitter components that matches the given name.

Parameters

stringThe name of the emitter to be deactivated.

NKSetController

Sets a character controller to manage this object.

Parameters

CharacterControllerThe controller to manage this object.

NKGetBounds

Retrieves bounding data for the graphics component.

Returns

BoundsBounding data for the graphics component.

NKGetAttachPosition

Retrieves the current position of a specified attach point (a sub-mesh suffixed with _atch) from the graphics component.

Parameters

stringThe name of the attach point.

Returns

vec3The current position of the attach point.

NKGetAttachPoint

OOLUA_MEM_FUNC( OOLUA::Lua_table_ref,
 NKGetAttachPoint,
const std::string &)

Returns a specified attachment point of a game object’s GraphicsComponent

Parameters

stringthe name of the attachment point

Returns

TableA LUA table in the format specified below or nil if no attach point with the provided name was found.
string m_name     - string name of the attachment point
vec3   m_position - the relative position of the attach point to the <GraphicsComponent>
quat   m_rotation - the relative rotation of the attach point to the <GraphicsComponent>

NKGetAttachmentOrientation

Returns a quaternion representing the rotation produced for attaching an object to this object at specific attach points.

Parameters

GameObjectThe object to be attached to this one.
stringThe name of the attach point in the attaching object.
stringThe name of the attach point in this object.

returns quat - The rotation resulting from attachment of the two points, or nil if the operation failed.

NKIsPhysicsDynamic

Returns whether or not the physics component is set to be dynamic or static.

Returns

boolTrue if physics is set to dynamic, false otherwise.

Scene

NKSetShouldRender

Sets the visibility state of this GameObject.

Parameters

boolIf true, this GameObject will be visible.
boolIf true, the assigned state will propagate to all child GameObjects.

NKShouldRender

Returns whether or not this object is set to render.

Returns

boolWhether or not this object is set to render.

NKPlaceInWorld

Add this GameObject to the visible world and physics simulation.

Parameters

bool : assignToTerrainIf true, this GameObject will be associated with the life-cycle of the cell it is spawned in.
bool : renderLastIf true, this object will always render last

NKRemoveFromWorld

Remove this GameObject from the visible world and physics simulation.

Parameters

bool : freeIf true, this GameObject is also freed from memory.  Any use of this object after this call is prohibited.
bool : removeFromTerrainIf true, this GameObject’s association with the terrain will also be removed.  Preventing it from being destroyed when its current terrain cell is reclaimed.

Transform

NKGetScale

Returns the parent relative scale of this object.

Returns

floatThe parent relative scale of this object or equivalent to NKGetWorldScale if this object does not have a parent.

NKGetWorldScale

Returns the world space scale of this object.

Returns

floatThe world space scale of this object.

NKScale

Set the scale of this object.

Parameters

scale : floatThe floating point scale (defaults to 1.0).
delta : boolIf true the provided scale is interpreted as a relative scale factor.
teleport : bool(optional, default true) If true will be interpreted as a discontinuity in remote clients interpolated views.

NKGetPosition

Returns the parent relative position of this object.

Returns

vec3The parent relative position of this object or equivalent to NKGetWorldPosition if this object does not have a parent.

NKGetWorldPosition

Returns the world space position of this object.

Returns

vec3The world space position of this object.

NKSetPosition

Set the position of this object in the world.

Parameters

vec3The position of the game object
bool(optional, default true) If true then the position will also move the physics representation of the object.
bool(optional, default false) If true the provided position is interpreted as a relative translation from this objects current position.
bool(optional, default true) If true then a client will “snap” to this position.  If false, a client will “interpolate” to this position.

NKGetOrientation

Returns the parent relative orientation of this object.

Returns

quatThe parent relative orientation of this object or equivalent to NKGetWorldOrientation if this object does not have a parent.

NKGetWorldOrientation

Returns the world space orientation of this object.

Returns

quatThe world space orientation of this object.

NKSetOrientation

Set the orientation of this object in the world.

Parameters

quatThe new orientation of this GameObject.
bool(optional, default true) If true the provided quat is interpreted as a relative rotation from this objects current orientation.
bool(optional, default true) If true then a client will “snap” to this orientation.  If false, a client will “interpolate” to this orientation.

NKSetAbsoluteScale

Sets the scale of this object such that it will appear at the size of the given scale, regardless of what its parent’s scale may be.

Parameters

floatThe scaling value.
teleport : bool(optional, default true) If true will be interpreted as a discontinuity in remote clients interpolated views.

Hierarchy

NKAddChildObject

Add a child object to this GameObject.

Note that the added object will be automatically removed from any previous parent.

Parameters

GameObjectThe child to add.

NKAddChildAtAttachPoint

Adds a child object to this object and attaches it to an attach point specified in the mesh.  Note that if one of the attaching objects hasn’t finished loading its model yet, this may initially fail and add that attachment to a pending queue that will complete when the models are loaded.  When this queu is completed, the script will receive a callback to the function “PendingAttachmentsCompleted” if that function exists.

Returns

boolTrue if the attachment was completed, false if it was queued.

Parameters

GameObjectThe game object to be attached.
stringThe name of the attach point in the child object.
stringThe name of the attach point in the parent object.
boolWhether or not the attachment should include orientation.

NKRemoveChildObject

Remove a child object to this GameObject.  Does nothing if the provided GameObject is not an attached child.

Parameters

GameObjectThe child to remove.

NKGetNumChildren

Returns the number of attached child GameObjects.

Returns

intthe number of attached children.

NKGetParent

Returns the parent GameObject of this object.

Returns

GameObjectthis objects parent, or nil if this object does not have a parent.

NKGetMaxStackCount

Returns the maximum stack count for a game object

Returns

intreturns the maximum number of items that can be stacked for this object

NKSetGraphics

Set the graphics component on this object

Parameters

GraphicsComponentThe StaticGraphicsComponent that will be attached to this object or nil to reset to default

NKGetGraphics

Get the base graphics component of this object

Returns

GraphicsComponentThe GraphicsComponent attached to this object, or nil if one is not attached.

NKGetStaticGraphics

Get the StaticGraphicsComponent attached to this GameObject.

Returns

StaticGraphicsComponentThe StaticGraphicsComponent attached to this object, or nil if one is not attached.

NKSetParent

Sets the parent of this GameObject to another.  The new child object will retain its position in world space.

Parameters

GameObjectThe new parent, or nil to clear the parent.

NKIsInWorld

Returns if the object has been placed in the world

Returns

boolTrue if in world, false if not

NKGetChildren

Returns a table containing all of this object’s children objects.

Returns

TableA list of all of this objects children objects.

Utility

NKGetName

Returns the type name of this GameObject.

Returns

stringThe type name of this GameObject.

NKGetInstance

This function is deprecated and scheduled for removal.  Using this function will print warnings (with stacktrace) to the console.  It used to retrieve the lua script instance associated with this GameObject, now this is done automatically.

NKDeleteMe

Destroys this object at the end of the frame.  This should always be used when a script wants to destroy itself.

NKSetAttachBone

Sets the bone this GameObject will attempt to follow in its parent object.

Note that when the parent changes, this GameObject will attempt to follow a like name bone in the new parent.

Parameters

stringThe name of the bone in the AnimatedGraphicsComponent of the parent GameObject to be rooted at.

NKClearAttachBone

Clears the bone attachment.

NKGetDisplayName

Retrieves the display name for this object, that is, the name that will appear in its name plate.

Returns

stringThe display name for this object.

NKGetStackCount

Retrieves the current stack count for this object.

Returns

intThe current stack count of this object.

NKSetStackCount

Sets the stack count for this item to the specified value.  Also safety checks to make sure the item doesn’t overflow its max stack count.

Parameters

intThe new stack count value.

Returns

intThe count left over after the stack count is set.  In the event the count is set to a number higher than its maximum, this will be the difference between the amount it was set to and its maximum.

NKModifyStackCount

Modifies this object’s stack count.

Parameters

intThe value to be added to the stack count (use negative values to decrease stack size).

Returns

intThe number of stacks that could not be added or removed from the stack, either because there was no more room, or because all stacks were removed.

NKSetMaxStackCount

Sets the max stack count for an object, overriding its settings from its data file.

Parameters

intThe new max stack count.

NKSetShouldSave

Tells this object whether or not it should allow saving.  This value defaults to true, and means that the object is capable of saving, not necessarily that it will.  Disabling it ensures that the object will not be saved.

Parameters

boolWhether or not this object should be capable of saving.

NKSetControllerCapsuleSize

Sets the size of this object’s controller’s capsule.

Parameters

floatSets the height of the capsule
floatSets the radius of the capsule

NKGetWorldPlayer

Gets the world player of this object if there is one

Return

WorldPlayerThe WorldPlayer associated with this object, can be nil

NKEnableScriptProcessing

Enable the script’s update function every frame or with an optional tick rate in milliseconds.  Do not enable this unless you need your script to have an update call.  Calling a Lua function from the engine is expensive.  Specifying a tick rate does not guarantee you will receive an update precisely at this interval every frame.  It represents the minimum wait time before calling the script process function again.  The accumulated delta time since the last update call will be passed in.  The larger the interval can be set, the better performance the engine will have.

Parameters

boolEnable the script processing
intTick Rate in milliseconds (optional parameter)

NKGetNetId

Return the network ID of this object

Returns

intthe 64bit network ID

NKRaiseScriptEvent

Send a network event between server and clients

Parameters

NetComponent::EventType typeeither NetComponent.SERVER_TO_CLIENT, NetComponent.CLIENT_TO_SERVER or NetComponent.SERVER_TO_ALL
string nameName of the event
table dataTable of data for that event
table receipients (opt.)A list of WorldPlayer to receive this event (for SERVER_TO_* events only)

NKSetShouldSaveChildren

Returns

BooleanWhether or not we should save our children.

NKRegisterScriptEvent

Internal function, creates new event type.  Use the wrapper function Class.RegisterScriptEvent(name, table) or Mixin.RegisterScriptEvent(name, table) instead.

Parameters

stringThe unique name of this event.
tableTable defining the event.

NKAddEmitterName

Adds emitter name to an attractor

Parameters

stringname of the emitter

NKLinkAttractorToEmitters

Links all emitters to attractors.  Use it on the object containing the attractors and emitters after adding emitter names to an attractors using NKAddEmitterName.

NKIsDistanceCulled

Returns whether or not the engine has culled this game object due to it’s distance away from the player based upon the object’s radius and the player’s view distance

Returns

booltrue if the object is distance culled (not visible to the player), or false if it isn’t (visible to the player)

NKGetRootParent

int staticNKGetRootParent(lua_State *vm)

Returns the root parent GameObject of this object’s hierarchy.

Returns

GameObjectthis objects root parent, or nil if this object does not have a parent.

NKSetWorldOrientation

int staticNKSetWorldOrientation(lua_State *l)

Sets the gameobject’s orientation in world space.

Parameters

quatthe world space orientation
booloverride physics (defaults true)
boolnetwork teleport (defaults true)
OOLUA_MEM_FUNC( OOLUA::Lua_table_ref,
 NKGetAttachPoint,
const std::string &)
Returns a specified attachment point of a game object’s GraphicsComponent
Component representing a GameObject’s graphics
int staticNKGetRootParent(lua_State *vm)
Returns the root parent GameObject of this object’s hierarchy.
int staticNKSetWorldOrientation(lua_State *l)
Sets the gameobject’s orientation in world space.
Component representing an instance of an animated mesh.
Component representing an instance of a morph target mesh.
Component representing a voxel material that can appear in the players inventory.
Component representing an instance of an static mesh.
A player in the game.
Close