Jump to content
Sign in to follow this  
Spriterfight

HELP How can i include a variable name in an array?

Recommended Posts

So i want a dead body(t4) to be spawned after the vehicle(t1) is destroyed.My code is this:

 

_pos = getPos [t1,0];
_unit = [t4,0];
_unit setPos [_pos,0];
_unit setDamage 1;

 

its says getpos:string expected object,location

Share this post


Link to post
Share on other sites

https://community.bistudio.com/wiki/getPos

 

Not sure where you got the idea to use those arrays.

 

_pos = getPos t1;
_unit = t4;
_unit setPos _pos;
_unit setDamage 1;

And as @Chewz points out, you don't need to redefine your object variables to local variables, at least within the scope of what you have shared here.

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Your code doesn't make any sense.

 

In order to get a position you simply need to do getPos <OBJECT>, not the array you did.

 

When assigning the _unit variable, you've defined the unit as an array, which won't work for both the setPos and setDamage commands.

 

This code below will work provided both t1 and t4 are assigned objects.

_Pos = getPosATL t1; // Gets the position of object 't1' at the terrain level.
t4 setPos _Pos; // Sets object 't4' to the position of 't1';
t4 setDamage 1; // Kills object 't4' (for some reason you want to do this)

// Ideally you then should delete t1
// deleteVehicle t1;
  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Thank you guys!I solved it with this 

_pos = position t1;
_unit = t4;
_unit setDamage 1;
_unit setPos _pos;

it works

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  

×