Effect Example
Jump to navigation
Jump to search
This example shows how to show an effect at the location of a specific entity in the simulation.
Let’s say you want to add a fire effect to a Jeep, and you know the entity ID of the Jeep is iJeepEntityId. You can get the 3d object handle to the Jeep as shown below:
int att3dObjectHandle = 0; GET_OTHER_ENTITY_ATT_BY_UNIT(iJeepEntityId, EntityWorld::ATT_3D_OBJECT_HANDLE, att3dObjectHandle, UNIT_TYPE_DEFAULT);
Then you can add an effect to the Jeep:
UINT effectId = 0; TriD::Effects::EffectAdd(_T(“GroundFire”), TriD::GetPartHandle(att3dObjectHandle, NULL), effectId);
The effect begins in an invisible state, but EffectAdd returns a handle to the effect (effectID) which you can use to activate or deactivate the effect as desired. Note: if you want to attach the effect to a specific subpart, replace NULL above with the subpart name.
Activate or deactivate the effect by calling EffectPlay with the effect ID and either true or false:
TriD::Effects::EffectPlay(effectId, true);
When activated, the effect appears as shown below: