Generate entity events||doc135514

September 20, 2022

Format

 ENTITY_ENTER
  • The class to which the function belongs:Entity

Description

This event is fired when an entity is spawned.


Precautions

useEntitySever.CreateWhen the entity object created by the function is used, this trigger will not be triggered. It will only be triggered when the entity object originally placed on the map by the editor and the NPC created by the blueprint.


Context

The context content of the event

name type Description
obj1 Entity Generated entity instance


Code Samples

On the server side of the entity templatemount script, register when the entity of this class is generatedCallbackbroadcast tipsentity object name

Trigger.RegisterHandler(this:cfg(), "ENTITY_ENTER", function(context)   --Entity generation event
    local entity = context.obj1
    World.CurWorld.SystemNotice(1, entity.name, 40)                     --Broadcast object name
end)