PDA

View Full Version : Triggers not working on spawned units


TEL79
11-12-2012, 11:30 AM
I tried to search the forums but found no light in how to make the triggers work on spawned units. I am trying to create a scoring system for air and ground kills, but it seems that all the vehicles and aircrafts that get script spawned, do not trigger neither passthrough nor destroyed type triggers. They are like "ghosts" in this sense. Another aprroach I tried was to override the OnActorDead method with scoring, but that resulted in funny things like planes freezing mid-air once the pilot was shot dead. Even the fuel leaked downwards on the planes like they were on the ground in this state.

Is there any way to make the triggers react to spawned units or what is the original OnActorDead function doing, which makes the planes behave like they should (fall down) once their pilot is dead.

I'm trying to recreate Operation Jubilee (Dieppe Landing) scene with LCAs spawning tanks and vehicles on the beach, but it would be nice to count the ground kills of these spawned units storming the beach.

FG28_Kodiak
11-13-2012, 04:45 AM
First do you have set
MissionNumberListener = -1;
example:

public override void OnBattleStarted()
{
base.OnBattleStarted();

MissionNumberListener = -1;
}


Second if you create an actor and you want a trigger like TGroupDestroyed attached to the actor you must create the trigger after the spawn of the actor.

Third i don't know how you use OnActorDead, but for me it works without a problem.


public void ActorDead(int missionNumber, string shortName, AiActor actor, List<DamagerScore> damages)
{
if (actor is AiAircraft)
{
// code for aircrafts
}
else if (actor is AiPerson)
{
// code for pilot or gunner kills (if needed)
}
else if (actor is AiGroundActor)
{
// code for destroyed groundactors
}
}

TEL79
11-13-2012, 07:32 AM
First do you have set
MissionNumberListener = -1;
example:

public override void OnBattleStarted()
{
base.OnBattleStarted();

MissionNumberListener = -1;
}


Second if you create an actor and you want a trigger like TGroupDestroyed attached to the actor you must create the trigger after the spawn of the actor.

Third i don't know how you use OnActorDead, but for me it works without a problem.


public void ActorDead(int missionNumber, string shortName, AiActor actor, List<DamagerScore> damages)
{
if (actor is AiAircraft)
{
// code for aircrafts
}
else if (actor is AiPerson)
{
// code for pilot or gunner kills (if needed)
}
else if (actor is AiGroundActor)
{
// code for destroyed groundactors
}
}


Thanks, I'll try the ActorDead approach later today. I don't know how to create a trigger in a script after the spawn, as I have so far created them using the GUI.

TEL79
11-16-2012, 06:52 AM
Now I got the scoring working as intended using the OnActorDead, thanks to Kodiak.

Now if only there was a way to get those spawned units to cause triggered events. I still don't understand why the scriptspawned units can't trigger the ArmyRedGround pass through triggers while every non-spawned do. How do implement a pass through trigger using the code?

Punch_145
01-29-2013, 02:27 PM
Regarding triggers not working on spawned units, is it possible to add a timout to an airgroup ?
Thinking if somehow you could delay a take off for a group then it would be loaded from mission start and a trigger could be implemented from it.