Skip to main content
Version: latest - a1.0.0 ⚖️

📦 Prop

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

info

Inheritance: This class inherits from Actor and Paintable. Please check their pages for inherited Methods and Events.

Usage#

local my_prop = Prop(  Vector(-900, 185, 215),  Rotator(0, 90, 90),  "nanos-world::SM_Crate_07")
Note

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

Note

Props bigger than radius 200 units will have Grabbable off by default. This can be overridden with :SetGrabbable().

Constructor Parameters#

TypeNameDefault ValueDescription
VectorlocationVector(0, 0, 0)Location to spawn
RotatorrotationRotator(0, 0, 0)Rotation to spawn
stringmodel_nameStatic Mesh to use
CollisionTypecollision_typeCollisionType.NormalCollision
booleangravity_enabledtrue
booleanis_grabbabletrue
booleanforce_no_ccdfalseForce CCD to not be used on small Props (may cause Props passing through objects if it's kinda small)

Functions#

Inherited Actor Functions
Base Actorscripting-reference/classes/base-classes/actor
ReturnsNameDescription
AddImpulseApplies a Force in world coordinate on this Actor
AttachToAttaches this Actor to any other Actor
DestroyDestroys this Actor
DetachDetaches this Actor if attached
SetCollisionSets the actor’s collision type
SetForceAdds a permanent force to this actor
SetGravityEnabledSets the actor’s gravity enabled
SetHighlightEnabledEnables this Actor Highlighting at a specific Index color
SetLifeSpanSets the actor’s life span to be destroyed
SetLocationSets the actor’s location in the game world
SetNetworkAuthoritySets this actor’s new Player Network Authority
SetRelativeLocationSets the actor’s relative location in local space
SetRelativeRotationSets the actor’s relative rotation in local space
SetRotationSets the actor’s rotation in the game world
SetScaleSets the actor’s scale
SetValueSets a value in this entity, which can be accessed by any package
TranslateToSmoothly moves this actor to a Location
RotateToSmoothly rotates this actor to a Rotation
booleanIsGravityEnabledGets the actor’s gravity enabled
booleanIsInWaterGets if the actor is in Water
booleanIsNetworkDistributedGets if the actor is Network Distributed
booleanIsValidReturns if this entity is valid (i.e. not destroyed)
tableGetAttachedEntitiesGets all actors attached to this entity
anyGetAttachedToGets the actor this actor is attached to
tableGetBoundsGets the actor bounds size
numberGetCollisionGets the current actor’s collision
numberGetIDGets the universal network ID of this entity
VectorGetLocationGet the actor’s position in the game world
VectorGetInitialLocationGets the initial location
RotatorGetRotationGets the actor’s rotation in the game world
VectorGetScaleGets the actor’s scale
stringGetTypeReturns the type of this Actor
anyGetValueGets a value given a key
VectorGetVelocityReturns the current actor Velocity
SubscribeSubscribes for an Event
UnsubscribeUnsubscribes from Events
Inherited Paintable Functions
Base Paintablescripting-reference/classes/base-classes/paintable
ReturnsNameDescription
SetMaterialReplace a materials of this actor with another Material
SetMaterialFromWebUIReplace a materials of this actor with a WebUI
SetMaterialColorParameterSets a Color parameter in this actor’s material
SetMaterialScalarParameterSets a scalar parameter in this actor’s material
SetMaterialTextureParameterLoads a image from computer (relative to Assets/ folder) and sets as parameter in this actor’s material
SetMaterialVectorParameterSets a Vector parameter in this actor’s material
ReturnsNameDescription
SetGrabbableSets ability to Characters to Grab this Prop
SetPhysicsDampingSets the Physics damping of this Prop
stringGetAssetNameGets the Asset name
CharacterGetHandlerGets the Character (if existing) which is holding this
booleanIsGrabbableGets ability to Grab this Prop

SetGrabbable#

Sets ability to Characters to Grab this Prop

my_prop:SetGrabbable(is_grabbable)
TypeParameterDescription
booleanis_grabbableIf the Prop will be able to be grabbable or not

SetPhysicsDamping#

Sets the Physics damping of this Prop

my_prop:SetPhysicsDamping(linear_damping, angular_damping)
TypeParameterDescription
numberlinear_damping
numberangular_damping

GetAssetName#

Gets the Asset name

Returns string

local asset_name = my_prop:GetAssetName()-- e.g. returns "nanos-world::SM_Cube"

GetHandler#

Gets the Character (if existing) which is holding this

Returns Character

local handler = my_prop:GetHandler()

IsGrabbable#

Gets ability to Grab this Prop

Returns boolean

my_prop:IsGrabbable()

Events#

Inherited Actor Events
Base Actorscripting-reference/classes/base-classes/actor
NameDescription
DestroyTriggered when an Entity is Destroyed
SpawnTriggered when an Entity is Spawned/Created
ValueChangeTriggered when an Entity has it’s value changed
NameDescription
GrabTriggered when Character grabs a Prop
HitTriggered when this Prop hits something
InteractTriggered when a Character tries to Grab up this
TakeDamageTriggered when a Prop takes Damage
UnGrabTriggered when Character ungrabs a Prop

Grab#

Triggered when Character grabs a Prop

Prop.Subscribe("Grab", function(self, character)
end)
TypeParameterDescription
PropselfThe 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)
end)
TypeParameterDescription
PropselfThe prop which has been hit
numberimpact_forceThe intensity of the Hit normalized by the Prop's weight
Vectornormal_impulseThe impulse direction it hits
Vectorimpact_locationThe world 3D location of the impact
VectorvelocityThe Prop velocity at the moment it hits

Interact#

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

Return false to prevent it

TypeParameterDescription
Propself
Charactercharacter

TakeDamage#

When Prop takes Damage

TypeParameterDescription
Propself
numberdamage
stringboneDamaged bone
DamageTypetypeDamage Type
Vectorfrom_directionDirection of the damage relative to the damaged actor
PlayerinstigatorThe player which caused the damage
anycauserThe object which caused the damage
Prop.Subscribe("TakeDamage", function(self, damage, bone, type, from_direction, instigator, causer)
end)

UnGrab#

Triggered when this Prop hits something

Prop.Subscribe("UnGrab", function(self, character)
end)
TypeParameterDescription
PropselfThe prop which has been ungrabbed
CharactercharacterThe old Grabber