OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: Bolgard on 10 May 2007, 11:27:09

Title: Want to spawn vehicle upon death of specific unit
Post by: Bolgard on 10 May 2007, 11:27:09
Greetings all - I have a very basic and elementary question - I've used the search function, but couldn't find the answer for what I'm looking for.

Basically, when a specific unit dies, I want to spawn a vehicle at a specific location on the map.  I've been trying to get this to work for several hours now - I've tried attaching the unit to a trigger and having the vehicle I want spawn at a marker -- in theory the trigger would go off when the unit is killed as he is connected to the trigger under the "not present" condition.

In the trigger I can spawn the vehicle with this line of code... but...

_ship = "PBX" createVehicle getMarkerPos "marker"

...the ship will spawn regardless of the health of the unit, and I'll get an error message (local variable in global space) but it will let me continue.  I know this has to be a very simple, unsophisticated result I want, and there must be a very easy and simple solution that I'm missing, but so far I'm stuck.

If you can help, I appreciate it :)  Much thanks!


-Bolgard
Title: Re: Want to spawn vehicle upon death of specific unit
Post by: Mandoble on 10 May 2007, 12:36:54
In the condition of the trigger put
Code: [Select]
damage yourunit > 0.9and in the activation:
Code: [Select]
ship1 = "PBX" createVehicle getMarkerPos "marker"
Title: Re: Want to spawn vehicle upon death of specific unit
Post by: 456820 on 10 May 2007, 22:52:12
Quote
and I'll get an error message (local variable in global space)

Reason for that is using an _ makes it local but a trigger is a global space.

So as Mandoble did was change it to just "ship" without the _. However in scripts you would use the _
Title: Re: Want to spawn vehicle upon death of specific unit
Post by: Bolgard on 11 May 2007, 01:26:46
Ah, thank you so much for the response - works perfectly, but leads to a silly followup question.  Unfortunately I can't get into the spawned boat - I assume there must be some other string or setting that needs to be written in that allows the player access to the spawned vehicle?
Title: Re: Want to spawn vehicle upon death of specific unit
Post by: Planck on 11 May 2007, 02:00:28
It sometimes takes a good few seconds after creation before you can use a creatvehicled vehicle.   :yes:

So, wait a while ......maybe 15 second or more, then try and board.


Planck
Title: Re: Want to spawn vehicle upon death of specific unit
Post by: Bolgard on 11 May 2007, 02:18:34
Ahh, ok, I'm a dumbass.  Gotcha.  Thanks  :good: