Skip to main content
Version: latest - a1.172.0 โš–๏ธ

๐Ÿ“ฆ Prop

A Prop represents a Dynamic Mesh which can be spawned in the world, can be grabbed around by characters and have physics

Client & Server๐Ÿ”Auto-Distributed๐Ÿง‘โ€๐Ÿ’ปAPI Source
๐Ÿ‘ชInheritance
This class shares methods and events from Base Entity, Base Actor, Base Paintable.

๐ŸŽ’ Examplesโ€‹

Server/Index.lua
local my_prop = Prop(
Vector(-900, 185, 215),
Rotator(0, 90, 90),
"nanos-world::SM_Crate_07"
)

๐Ÿ›  Constructorsโ€‹

Default Constructorโ€‹

No description provided

local my_prop = Prop(location, rotation, asset, collision_type?, gravity_enabled?, grab_mode?, ccd_mode?, spawn_mode?)
Parameters
NameTypeDescription
locationVectorWorld location to spawn at
rotationRotatorWorld rotation to spawn with
assetStaticMesh ReferenceThe asset to use
collision_type?CollisionTypeSetting CollisionType.Auto will make it automatically switch between Normal and IgnoreOnlyPawn if they are smaller than radius 40 units Default CollisionType.Auto
gravity_enabled?booleanWhether gravity affects this Actor Default true
grab_mode?GrabModeWhether or not the Prop can be grabbed Default GrabMode.Auto
ccd_mode?CCDModeWhether or not the Prop should have CCD enabled (disabling it may cause Props passing through objects if it's kinda small). It's smart to force it disabled on 'visual only' props Default CCDMode.Auto
spawn_mode?SpawnModePass SpawnMode.AfterConstructor or SpawnMode.Manual to avoid immediately sending the entity to clients and improve performance when you want to configure it by setting several configs. Must call FinishSpawn() after all Default SpawnMode.Immediate
info

If the Prop was spawned by the Client. It will have all interactions disabled (e.g. it will not be able to be grabbed by Characters).

info

Props smaller than radius 40 units or very thin (any side smaller than 20 units) will have CCD (Continuous Collision Detection) enabled automatically to avoid falling through the floor or other objects. This will slightly increase the performance cost of them!

๐Ÿ—ฟ Static Functionsโ€‹

This class doesn't have own static functions.

Inherited static functions

๐Ÿฆ  Functionsโ€‹

Appearance
GetMesh: StaticMesh ReferenceGets the Asset name
SetInteractionToolTipTextSets the interaction tooltip text shown when a Character interacts with this Prop
SetMeshChanges the mesh in runtime
Handling
GetGrabMode: GrabModeGets ability to Grab this Prop
GetHandler: Character or nilGets the Character (if existing) which is holding this
SetGrabModeSets ability to Characters to Grab this Prop
Physics
GetMassOverride: floatGets the overridden mass
GetMassScale: floatGets the mass scale
IsOneWayInteraction: booleanGets whether one-way interaction is enabled on this Prop
SetBuoyancyPontoonsSets the Buoyancy Pontoons used by the Water simulation
SetBuoyancySettingsSets how this entity behaves on Water
SetMassOverrideOverride the mass (in Kg) of this Prop
SetMassScaleChange the mass scale used to calculate the mass of this Prop
SetOneWayInteractionSets whether this Prop treats every physics body without it as infinitely heavy, so they push it around but never get pushed back
SetPhysicsDampingSets the Physics damping of this Prop

Inherited functions

Appearancefunctionsโ€‹

GetMeshOptimalโ€‹

Gets the Asset name

local asset = my_prop:GetMesh()
Returns
TypeDescription
StaticMesh Referenceasset name

See also SetMesh.

SetInteractionToolTipTextOptimalโ€‹

Sets the interaction tooltip text shown when a Character interacts with this Prop

my_prop:SetInteractionToolTipText(tool_tip_text)
Parameters
NameTypeDescription
tool_tip_textstringText to show in the interaction tooltip

SetMeshSlowโ€‹

Changes the mesh in runtime

my_prop:SetMesh(asset)
Parameters
NameTypeDescription
assetStaticMesh Referenceasset

See also GetMesh.

Handlingfunctionsโ€‹

GetGrabModeOptimalโ€‹

Gets ability to Grab this Prop

local grab_mode = my_prop:GetGrabMode()
Returns
TypeDescription
GrabModeAbility to Grab this Prop

See also SetGrabMode.

GetHandlerOptimalโ€‹

Gets the Character (if existing) which is holding this

local handler = my_prop:GetHandler()
Returns
TypeDescription
Character or nilthe character that holds the object

SetGrabModeOptimalโ€‹

Sets ability to Characters to Grab this Prop

my_prop:SetGrabMode(grab_mode)
Parameters
NameTypeDescription
grab_modeGrabModeIf the Prop will be able to be grabbable or not. Set to Auto to automatically define based on Prop's size

See also GetGrabMode.

Physicsfunctionsโ€‹

GetMassOverrideOptimalโ€‹

Gets the overridden mass

local ret = my_prop:GetMassOverride()
Returns
TypeDescription
floatThe overridden mass

See also SetMassOverride.

GetMassScaleModerateโ€‹

Gets the mass scale

local ret = my_prop:GetMassScale()
Returns
TypeDescription
floatThe mass scale

See also SetMassScale.

IsOneWayInteractionOptimalโ€‹

Gets whether one-way interaction is enabled on this Prop

local ret = my_prop:IsOneWayInteraction()
Returns
TypeDescription
booleanNo description provided

See also SetOneWayInteraction.

SetBuoyancyPontoonsModerateโ€‹

Sets the Buoyancy Pontoons used by the Water simulation

Sets the spherical Pontoons used to float this entity on Water, overriding the ones automatically calculated from the Mesh bounds and mass.

Pass no value (or an empty table) to go back to the automatically calculated ones.

Pontoons only have an effect on Maps with Water Buoyancy enabled

my_prop:SetBuoyancyPontoons(pontoons?)
Parameters
NameTypeDescription
pontoons?tableArray with the Pontoons, or nil to restore the automatically calculated ones Default nil
Table keys
NameTypeDescription
OffsetVectorLocation relative to the entity
RadiusfloatRadius of the Pontoon sphere, must be greater than 0

SetBuoyancySettingsModerateโ€‹

Sets how this entity behaves on Water

Any value passed as nil restores that setting's default.

The automatically calculated Pontoons are sized for the default buoyancy_coefficient, so a higher one makes the entity float higher

my_prop:SetBuoyancySettings(enabled?, buoyancy_coefficient?, buoyancy_damp?, max_buoyant_force?)
Parameters
NameTypeDescription
enabled?booleanWhether Buoyancy forces are applied at all Default true
buoyancy_coefficient?floatHow much it floats, the higher the more Default 0.1
buoyancy_damp?floatFirst order damping on the vertical velocity, reduces bobbing. When nil (or negative) it is calculated from the mass and Pontoons Default nil
max_buoyant_force?floatClamp on the upwards force, stops light objects being launched out of the water Default 1000000000

SetMassOverrideOptimalโ€‹

Override the mass (in Kg) of this Prop

my_prop:SetMassOverride(mass)
Parameters
NameTypeDescription
massfloatMass in KG to override. Pass -1 to reset to default

See also GetMassOverride.

SetMassScaleModerateโ€‹

Change the mass scale used to calculate the mass of this Prop

my_prop:SetMassScale(scale)
Parameters
NameTypeDescription
scalefloatThe new mass scale used to calculate the mass of this Prop

See also GetMassScale.

SetOneWayInteractionOptimalโ€‹

Sets whether this Prop treats every physics body without it as infinitely heavy, so they push it around but never get pushed back

my_prop:SetOneWayInteraction(one_way_interaction)
Parameters
NameTypeDescription
one_way_interactionbooleanNo description provided

See also IsOneWayInteraction.

SetPhysicsDampingOptimalโ€‹

Sets the Physics damping of this Prop

my_prop:SetPhysicsDamping(linear_damping, angular_damping)
Parameters
NameTypeDescription
linear_dampingfloatLinear damping value
angular_dampingfloatAngular damping value

๐Ÿš€ Eventsโ€‹

GrabTriggered when Character grabs a Prop
HitTriggered when this Prop hits something
InteractWhen a Character interacts with this Prop (i.e. try to Grab it)
TakeDamageWhen Prop takes Damage
UnGrabTriggered when this Prop is ungrabbed

Grabโ€‹

Triggered when Character grabs a Prop

Prop.Subscribe("Grab", function(self, character)
-- Grab was called
end)
Arguments
NameTypeDescription
selfPropThe prop which was Grabbed
characterCharacterThe new Grabber

Hitโ€‹

Triggered when this Prop hits something

Prop.Subscribe("Hit", function(self, impact_force, normal_impulse, impact_location, velocity, other_actor)
-- Hit was called
end)
Arguments
NameTypeDescription
selfPropThe prop which has been hit
impact_forcefloatThe intensity of the Hit normalized by the Prop's weight
normal_impulseVectorThe impulse direction it hits
impact_locationVectorThe world 3D location of the impact
velocityVectorThe Prop velocity at the moment it hits
other_actorBase Actor or nilThe other actor that hit this Prop

Interactโ€‹

When a Character interacts with this Prop (i.e. try to Grab it)

Prop.Subscribe("Interact", function(self, character)
-- Interact was called
return true
end)
Arguments
NameTypeDescription
selfPropthe object that undergoes an interaction
characterCharacterthe character who interacts with the object
Returns
TypeDescription
booleanReturn false to prevent the interaction (i.e. prevent being grabbed)

TakeDamageโ€‹

When Prop takes Damage

Prop.Subscribe("TakeDamage", function(self, damage, bone, type, from_direction, instigator, causer)
-- TakeDamage was called
end)
Arguments
NameTypeDescription
selfPropthe object that takes the damage
damageintegeramount of damage
bonestringDamaged bone
typeDamageTypeDamage Type
from_directionVectorDirection of the damage relative to the damaged actor
instigatorPlayer or nilThe player which caused the damage
causerBase Actor or nilThe object which caused the damage

UnGrabโ€‹

Triggered when this Prop is ungrabbed

Prop.Subscribe("UnGrab", function(self, character)
-- UnGrab was called
end)
Arguments
NameTypeDescription
selfPropThe prop which has been ungrabbed
characterCharacterThe old Grabber