Add special effects||doc135474

September 20, 2022

Format

 Entity:addEffect(name, effectName, once, pos, yaw, scale, socketName) 
  • The class to which the function belongs:Entity

Description

Add playback effects to entity objects.


Parameters

Variable name type Description
name string Name, as the key to use when deleting
effectName string Effect name
once boolean Play once, default false
pos Vector3 Relative hanging point position, default { x = 0, y = 0, z = 0 }
yaw float yaw axis rotation, default value 0
scale Vector3 scaling, default { x = 1, y = 1, z = 1 }
socketName string The name of the character's attachment point, the default value is an empty string


Code Samples

On the server side of the player entity templatemount script, when a registered player logs inCallback, send the communication protocol

Trigger.RegisterHandler(this:cfg(), "ENTITY_ENTER", function(context)
    local player = context.obj1
    PackageHandlers.sendServerHandler(player, "ClientTest", {})
end)

on the client sideglobal script, register the client communication protocol, when the event is activated, add special effects for the specified player.

PackageHandlers.registerClientHandler("ClientTest", function(player, packet)
     if player then
        player:addEffect("login_" .. userId, "asset/Effect/Life/88_foot.effect")
    end
end)