sm.effect
Associated object type: Effect
The effect api handles the creation and playing of audio and visual effects.
Effects can consist of multiple components each being of separate types and with unique offsets, rotations and delays.
For more information on how to setup effects please take a look in the Effects/Database/EffectSets folder in the game data.
Functions
createEffect
sm.effect.createEffect( name, host, bone )
Client-Only
Creates an effect.
If you provide a host object to the effect then it will fetch position,
velocity and orientation data from the object instead of relying on this information being fed to it.
This results in far more accurate positioning of effects that are supposed to stay attached to an object.
Arguments:name
[ string ]: The effect name.host
[ Interactable / Harvestable / Character / nil ]: The object that the effect is attached to.bone
[ string ]: The bone name, if attaching to an interactable or character. Defaults to none.
- [ Effect ]: The created effect.
createEffect2D
sm.effect.createEffect2D( name )
Client-Only
Creates a 2D effect.
Arguments:name
[ string ]: The effect name.
- [ Effect ]: The created effect.
estimateSize
sm.effect.estimateSize( name, params )
Client-Only
Estimates the radius of influence for an effect and instance parameters.
Arguments:name
[ string ]: The effect name.params
[ table ]: The parameters.
- [ number ]: The range.
playEffect
sm.effect.playEffect( name, position, velocity, rotation, scale, parameters )
Plays an effect. If this function is called on the server it will play the effect on all clients.
If you start a looping effect using this function you will not be able to stop it.
Please use createEffect for looping effects.
name
[ string ]: The effect name.position
[ Vec3 ]: The position.velocity
[ Vec3 ]: The velocity. Defaults to none.rotation
[ Quat ]: The rotation. Defaults to none.scale
[ Vec3 ]: The scale, if using a renderable. Defaults to none.parameters
[ table ]: The table containing effect parameters. Defaults to none.
playHostedEffect
sm.effect.playHostedEffect( name, host, boneName, parameters )
Client-Only
Plays an effect.
It will fetch position, velocity and orientation data from the host object.
If you start a looping effect using this function you will not be able to stop it.
Please use createEffect for looping effects.
name
[ string ]: The effect name.host
[ Interactable / Harvestable / Character ]: The object that the effect is attached to.bone
[ string ]: The bone name, if attaching to an interactable or character. Defaults to none.parameters
[ table ]: The table containing effect parameters. Defaults to none.