Jump to content
Sign in to follow this  
lockjaw-65-

assigned driver etc

Recommended Posts

Having real trouble getting my head round this!

where would you place the syntax to get the unit to enter a position in a vehicle, if both the unit and vehicle have been created while the game is running? on the trigger, in the script that creates the units, I just dont know and have tried various ways for the last 2 days

Share this post


Link to post
Share on other sites

You can do it anywhere you want.

Just make sure that you give those created objects a name, so you can refer to it.

If you just create a unit via "_unitType createUnit [_pos, _group]", you have no way to refer to that unit (and this is probably where your frustration comes from).

To access it in scripts, triggers, etc., name it via the createUnit command's init field:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_unitType createUnit [_pos, _group, "myUnit=this"];This assigns the newly created unit to the variable "myUnit", which can then be used anywhere in the game, just as if it were created in the editor.

You can also use a similar approach with the alternative createUnit command, which returns the created object (e.g. _unit = _group createUnit [blah,blah,blah]). As long as you stay in the same script you can use that returned _unit variable in other commands. If you need it outside of the script, either put it into a global variable, or assign it via <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">call compile "myUnit = _unit"

The same principle applies to vehicles (just that none of the createVehicle commands have the option to specify an init string, so you have to use the second method of naming it (via "call compile").

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  

×