hit object event||doc135605

September 20, 2022


  • The class to which the function belongs:Missile


This event is fired when a projectile hits an object.


The context content of the event

name type Description
obj1 Entity the instance of the object hit by the projectile
obj2 Entity the object instance that fires the projectile
missile Missile projectile example

Code Samples

Find the corresponding projectile in the editor, right-click to copy its ID, plus the prefix is its name, such as 'myplugin/testMissile'

on the server sideglobal script, register when a projectile of this class hits an objectCallbackbroadcast tipshit relationship

local testMissileCfg =  Missile.GetCfg("myplugin/testMissile")               --Get missile config
Trigger.RegisterHandler(testMissileCfg, "HIT_ENTITY", function(context)
   local target = context.obj1
   local from = context.obj2
   local missile = context.missile
   World.CurWorld.SystemNotice(1,from.name .. "  hit  " .. target.name, 40)  --Broadcast