Hit the block event with the ray skill||doc135536

September 20, 2022

Format

 HIT_BLOCK_BY_RAY
  • The class to which the function belongs:Entity

Description

This event is triggered when the entity object hits a block with the ray ability.


Context

The context content of the event

name type Description
obj1 Entity the object instance that fires the projectile
pos Vector3 block coordinates


Code Samples

On the server side of the entity templatemount script, register when this type of entity object hits a block with a ray skillCallback, remove the hit block

Trigger.RegisterHandler(this:cfg(), "HIT_BLOCK_BY_RAY", function(context)
    local from = context.obj1
    local blockPos = context.pos
    local map = from.map             --Get the current object location map
    map:removeBlock(blockPos)        --Remove blocks based on the coordinates of the hit block
end)