The fsVfxSpawnOnSimObject function can be used to spawn a visual effect on a SimObject.


FsVfxId fsVfxSpawnOnSimObject(
    const char* strGuid,
    FsSimObjId simObjId = 0,
    const char* nodeName = nullptr,
    FsVec3d offset = { 0, 0, 0 },
    FsVec3d pbhOffset = { 0, 0, 0 },
    float minEmissionTime = -1.f,
    FsVfxGraphParam * graphParams = nullptr,
    int graphParamsSize = 0


Parameters Description
strGuid The GUID guid of the vfx to spawn, as a string, for example: "7E68323C-E75D-4F5B-988E-65DD4956F6BA". This is a required parameter with no default value.
simObjId The ID of the SimObject on which the VFX will be spawned. You may pass in the value 0, which is a special value used to specifiy the current user object. Default value is: 0
nodeName The name of the node to which the VFX will be attached. If nullptr is given, the VFX will be attached to the root node of the SimObject. Default value is: nullptr
offset This is the position offset, in meters, of the VFX when spawned. The offset is specified as an array of latitude, longitude and altitude values, relative to the position of the node the VFX is attached to. The default is: {0, 0, 0}
pbhOffset This is the rotation offset, in degrees, of the VFX when spawned. The offset is specified as an array of pitch, bank and heading, all relative to the node that the VFX is attached to. The default is: {0, 0, 0}
minEmissionTime The time from which fsVFXIsMinTimePassed will be TRUE. Reaching this time has no other impact on the VFX, and if set to -1 then fsVFXIsMinTimePassed will be TRUE from the moment the VFX instance is spawned. The default is: -1.f
graphParams An array of graph parameters for the VFX. The default is: nullptr
graphParamsSize The size of the graphParams array. The default is: 0

Return Values

The function returns a VFX ID which can be used in most of the other VFX API functions. If something has gone wrong and the function fails, FSVFXID_NULL will be returned. The VFX creation may fail if:

  • the pointer to strGuid is not valid
  • the VFX associated with the GUID is not loaded into the game (possibly because the VFX doesn't exist)
  • no sim object is associated with the given simObjId
  • the pointer to nodeName is not valid
  • no node with the given nodeName has been found on the SimObject
  • the VFX has been spawned to far away (ie: further than all the MaxEmissionDistance of the emmiters)
  • the SimObject on which the effect has been spawned is not fully load into the world
    NOTE: In the case of AI aircraft there is no way to be sure when loading is finished, so retrying is the only solution.


FsVec3d offset = { 0, 0, -5 };
FsVfxGraphParam graphParams[3];
graphParams[0].paramName = "ColorR";
graphParams[0].RPNExpression = "1";
graphParams[1].paramName = "ColorG";
graphParams[1].RPNExpression = "0";
graphParams[2].paramName = "ColorB";
graphParams[2].RPNExpression = "(A:ELEVATOR DEFLECTION PCT, Percent Over 100)";
g_SpawnVars.fxBackId = fsVfxSpawnOnSimObject("AAF9ECBE-C092-429A-877B-D41357D1E519", 0, nullptr, offset, { 0,0,0 }, -1, graphParams, 3);



When spawned a VFX instance will start playing automatically. Also note that all VFX that you spawn on SimObjects should be destroyed when no longer required using the fsVfxDestroyInstance function.


See Also