Jump to content
Sign in to follow this  
atledreier

Proximity trigger on a randomly placed object

Recommended Posts

I have a training mission where the players have to find an object to clear the task.

I have a burning barrel with placement radius og 50m

Init

_nul=execVM "BarrelTrigger.sqf"

Script

Barreltrigger.sqf

_Pos=getpos Barrel;
_BarrelTrigger = createTrigger ["BarrelTrigger", _Pos];
_BarrelTrigger setTriggerActivation ["WEST", "PRESENT", false];
_BarrelTrigger setTriggerStatements ["this", "BarrelFound = true",""];

For debugging I have a trigger that activates if Barrelfound is true, but that never fires.

What am I missing?

Share this post


Link to post
Share on other sites

you can also use nearestObjects to accomplish this.

something like this.

_radius = 50;
_classes = ["Man","Car","Tank","bla bla"];

while {!BarrelFound} do
{
   _objects = nearestObjects [barrel,_classes,_radius];
   if (count _objects > 0) then {BarrelFound = true;};
   sleep 1;
};
hint "BarrelFound";

alltho this doesnt check which side the _object is on. to do that you can replace the if in the loop with something like this,

for "_i" from 0 to (count _objects -1) do
{
   if (side _objects select _i == WEST) then {BarrelFound = true;};
};

this is not related to triggers. but another way to solve the problem, :)

ps nothing is tested. only pseudo code

Edited by nuxil

Share this post


Link to post
Share on other sites

great timing for this thread bcoz i need the same question answered -

i have "box1" that had 3 random spawns around the map and i want a trigger to fire that objective is complete when you walk up to the box.

how to do it though?

thanx

Lighty

Share this post


Link to post
Share on other sites

Name the trigger and attach it to the box.

nameOfTrigger attachTo[box1, [0,0,0]];

in the box's init.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×