Generate client entity||doc135513

September 20, 2022

Format

 EntityClient.CreateClientEntity(params) 

Description

Creating an entity object on the client side requires the same entity configuration information as creating an entity object on the server side.


Precautions

  • Entity objects created on the client side will not be synchronized to other clients, only the current client can display them.
  • The client entity has no AI function
  • Be careful not to create objects when the program starts running, at least when the map is loaded, otherwise unimaginable consequences will occur

Parameters

Variable name type Description
params CreateParams Create parameters


Value Returned

type Description
Entity entity object


Code Samples

Find the corresponding entity in the editor, right-click to copy its ID, plus the prefix is its configuration name (cfgName), such as 'myplugin/entity'

on the client sideglobal script, generate the client entity

local createParams = { cfgName = "myplugin/entity", pos = { x = 0, y = 1, z = 0 } }
local entity = EntityClient.CreateClientEntity(createParams)