hit block event||doc135606

September 20, 2022

Format

 HIT_BLOCK
  • The class to which the function belongs:Missile

Description

Triggered when the projectile hits a block.


Precautions

  • Only triggers the hit event when the projectile's properties are set to hit a block will only take effect.

Context

The context content of the event

name type Description
obj1 Entity the object instance that fires the projectile
pos Vector3 block coordinates
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 this type of projectile hits a blockCallbackbroadcast tipsthe object's name

local testMissileCfg =  Missile.GetCfg("myplugin/testMissile")    --Get missile config
Trigger.RegisterHandler(testMissileCfg, "HIT_BLOCK", function(context)  
   local entity = context.obj1
   local pos = context.pos
   World.CurWorld.SystemNotice(1, entity.name, 40)                --Broadcast entity name
end)