Mesh
An Entity can have a single physical representation. Mesh is for 3D objects that exist in the scene. They can be collided with and recieve damage when hit. Mesh derives from Entity so if you have a Mesh you can do any of these functions as well as the functions in Entity. You can do entity:IsA(Mesh) to see if a particular entity variable is a Mesh type entity.
Parent: Entity
Functions
Function Name | Usage | Description | Notes |
---|---|---|---|
PlayAnimation | AnimationHandle mesh:PlayAnimation(string animationName) |
Play a named animation on this mesh, once. | |
PlayAnimation | AnimationHandle mesh:PlayAnimation(string animationName, bool looping) |
Play a named animation on this mesh, optionally looping. | |
PlayAnimation | AnimationHandle mesh:PlayAnimation(string animationName, table properties) |
Play a named animation on this mesh, optional table can contain named values looping , either playbackTime or playbackSpeed and either 'positionFactor' or 'positionTime' a negative playbackSpeed will play the animation in reverse. For example playbackSpeed = -2 will play the animation twice as fast in reverse Example |
|
PlayAnimationLooping | AnimationHandle mesh:PlayAnimationLooping(string animationName) |
Play a named animation on this mesh, repeatedly. | |
PlayAnimationLooping | AnimationHandle mesh:PlayAnimationLooping(string animationName, table properties) |
This is the same as the PlayAnimation function taking a table containing playbackTime or playbackSpeed except that looping defaults to true |
|
PlayAnimationClient | mesh:PlayAnimationClient(string animationName) |
Use PlayAnimation instead, works on client or server | Deprecated |
PlayAnimationClient | mesh:PlayAnimationClient(string animationName, bool looping) |
Use PlayAnimation instead, works on client or server | Deprecated |
PlayAnimationLoopingClient | mesh:PlayAnimationLoopingClient(string animationName) |
Use PlayAnimation instead, works on client or server | Deprecated |
GetAnimationNames | table mesh:GetAnimationNames() |
Get a table of animation names that you can play on this mesh with PlayAnimation. | |
GetAnimationLength | number mesh:GetAnimationLength(string animationName) |
Get the length of an animation in seconds | |
CreateThruster | Thruster mesh:CreateThruster() |
Add a thruster to an entity | |
CreateRelativeThruster | Thruster mesh:CreateRelativeThruster() |
||
DestroyThruster | mesh:DestroyThruster(Thruster handle) |
Destroy a thruster | |
AddImpulse | mesh:AddImpulse(Vector impulse) |
Add Impulse. An integral of force over a time interval. Newton seconds. | |
AddAngularImpulse | mesh:AddAngularImpulse(Rotation angularImpulse) |
Add Angular Impulse. An integral of torque over a time interval. Newton seconds. |
Parameters
Parameter Name | Usage | Description | Notes |
---|---|---|---|
collisionEnabled | bool collisionEnabled |
Turn on or off collision (ie calling entry point OnCollision). | |
damageEnabled | bool damageEnabled |
Turn on or off damage (ie calling of entry point OnDamaged). | |
physicsEnabled | bool physicsEnabled |
Turn on or off physics. | |
gravityEnabled | bool gravityEnabled |
Turn on or off physics. | |
onCollision | Event onCollision |
Called when this entity is collided with by a player Character with the Character passed as an argument, as well as the mesh Entity from which the onCollision event was triggered. An alternative to listening for OnCollision in a script on the entity. | |
onDamage | Event onDamage |
Called when this entity is damaged with the amount of damage, the entity causing the damage and a HitResult structure, as well as the mesh Entity from which the onDamage event was sent. An alternative to listening for OnDamage in a script on the entity. | |
mesh | meshno mesh |
Get or change the mesh | |
meshScale | vector meshScale |
Get or change the scale |
Overrides
Override Name | Usage | Description | Notes |
---|---|---|---|
new_index | mesh.var = object value |
Examples
AnimationHandle mesh:PlayAnimation(string animationName, table properties)
The following code plays the active
animation looped, starting at 50% of the way through the animation, and makes each full cycle take 1 second no
matter how long the animation is. To find out what animations are available on a mesh entity hover over the "Animations" button
in the property editor.
self:GetEntity():PlayAnimation("active", { looping = true, playbackTime = 1.0, positionFactor = 0.5 })