Home   Help Search Login Register  

Author Topic: Want to spawn vehicle upon death of specific unit  (Read 1661 times)

0 Members and 1 Guest are viewing this topic.

Offline Bolgard

  • Members
  • *
Want to spawn vehicle upon death of specific unit
« 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

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Want to spawn vehicle upon death of specific unit
« Reply #1 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"

Offline 456820

  • Contributing Member
  • **
Re: Want to spawn vehicle upon death of specific unit
« Reply #2 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 _

Offline Bolgard

  • Members
  • *
Re: Want to spawn vehicle upon death of specific unit
« Reply #3 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?

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re: Want to spawn vehicle upon death of specific unit
« Reply #4 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
I know a little about a lot, and a lot about a little.

Offline Bolgard

  • Members
  • *
Re: Want to spawn vehicle upon death of specific unit
« Reply #5 on: 11 May 2007, 02:18:34 »
Ahh, ok, I'm a dumbass.  Gotcha.  Thanks  :good: