Static Mesh

https://i.imgur.com/DLysSYP.png

A StaticMesh entity represents a Mesh which can be spawned in the world, can’t move and is more optmized for using in decorating the world.

Tip

You can spawn this entity is both Client or Server (if you spawn it on client, it won’t be synchronized with other players).

Usage

local static_mesh = StaticMesh(
  Vector(-900, 185, 215),
  Rotator(0, 90, 90),
  "NanosWorld::SM_Crate_07"
)

Constructor Parameters

Type

Name

Default

Vector

location

Vector(0, 0, 0)

Rotator

rotation

Rotator(0, 0, 0)

string

model_name (StaticMesh)

number

collision_type

0 (Normal)

Functions

Returns

Name

Description

SetDefaultMaterial(number material_type = 1)

Replaces all materials of this actor with a nanos basic material with comon parameters available (1 - Masked, 2 - Translucent)

SetMaterialColorParameter(string parameter_name, Color color)

Sets a Color parameter in this actor’s material

SetMaterialScalarParameter(string parameter_name, number scalar)

Sets a scalar parameter in this actor’s material

SetMaterialTextureParameter(string parameter_name, string texture_path)

Loads a image from computer (relative to Assets/ folder) and sets as parameter in this actor’s material

SetMaterialVectorParameter(string parameter_name, Vector vector)

Sets a Vector parameter in this actor’s material

string

GetAssetName()

Gets the Asset name

Note

The following methods AddImpulse & SetGravityEnabled don’t have effect on this actor.

Functions (Inherited from Actor)

Returns

Name

Description

server-only-label

AddImpulse(Vector force)

Applies a Force in world coordinate on this Actor (the force is applied on Client side, by the (in most of cases) the closest player of this object)

server-only-label

AttachTo(Actor other, string bone_name, Vector relative_location, Rotator relative_rotation)

Attaches this Actor to any other Actor with a Relative Offset/Rotation

server-only-label

Destroy()

Destroys this Actor

server-only-label

SetCollision(number collision_type)

Sets the actor’s collision (0 - Normal, 1 - Static Only, 2 - No Collision)

server-only-label

SetGravityEnabled(boolean new_gravity)

Sets the actor’s gravity enabled

client-only-label

SetHighlightEnabled(boolean enabled)

Sets if this Actors is Highlighting

server-only-label

SetInitialLocation(Vector new_initial_location)

Sets the initial location

server-only-label

SetLocation(Vector new_location)

Sets the actor’s location in the game world

server-only-label

SetMaterialColorParameter(string parameter_name, Color color, number material_index = -1)

Sets a Color parameter on a material of this actor, optionally on a specific material index or -1 for all materials

server-only-label

SetMaterialScalarParameter(string parameter_name, number scalar, number material_index = -1)

Sets a Scalar parameter on a material of this actor, optionally on a specific material index or -1 for all materials

server-only-label

SetMaterialTextureParameter(string parameter_name, string texture_path, number material_index = -1)

Loads and sets a Texture parameter on a material of this actor, optionally on a specific material index or -1 for all materials

server-only-label

SetMaterialVectorParameter(string parameter_name, Vector vector, number material_index = -1)

Sets a Vector parameter on a material of this actor, optionally on a specific material index or -1 for all materials

server-only-label

SetRotation(Rotator new_rotation)

Sets the actor’s rotation in the game world

server-only-label

SetScale(Vector Scale)

Sets the actor’s scale

server-only-label

SetTintColor(Color new_tint_color)

Sets the tint color, for completely paint an object, multiply the color by 10 or 100

SetValue(string key, any value)

Sets a value in this entity, which can be accessed by any package (local only)

TranslateTo(Vector location, number speed)

Smoothly moves this actor to a Location with a certain Speed

RotateTo(Rotator rotation, number speed)

Smoothly rotates this actor to a Rotation with a certain Speed

boolean

IsGravityEnabled()

Gets the actor’s gravity enabled

boolean

IsInWater()

Gets if the actor is in Water

boolean

IsValid()

Returns if this is Valid

number

GetCollision()

Gets the current actor’s collision

number

GetID()

Gets the network ID of this entity (same in both client and server)

Vector

GetLocation()

Get the actor’s position in the game world

server-only-label

Vector

GetInitialLocation()

Gets the initial location

Rotator

GetRotation()

Gets the actor’s rotation in the game world

Vector

GetScale()

Gets the actor’s scale

Color

GetTintColor()

Gets the Tint Color

string

GetType()

Returns the type of this Actor

any

GetValue(string key)

Gets a value given a key

client-only-label

Vector

GetVelocity()

Returns the current actor Velocity

Events

Events (Inherited from Actor)

Name

Arguments

Description

Destroy

Entity actor

Triggered when an Entity is Destroyed

Spawn

Entity actor

Triggered when an Entity is Spawned/Created

ValueChange

Entity actor,
string key,
any value

Triggered when an Entity has it’s value changed