Array object Move :P
#1

Its have a little question i cannot fix it so now i can create array but its not moving how to make it move all of array ?
pawn Code:
MoveObject(obj[177], 0, 0, -50, 2.00);
This my move object code i have obj[177] how i can move object all of array ?
Reply
#2

If you mean you want to move all the objects created in ojb[x], do it like this:

pawn Code:
for(new i = 0; i < sizeof(obj); i++)
    {
    MoveObject(obj[i], 0, 0, -50, 2.00);
    }
And if you need different positions for the objects to move I recommend using a multidimensional array, like this:
pawn Code:
new objpos[x][3] = {
{0.00, 0.00, -50.00},
{0.00, 0.00, -40.00},
};

for(new i = 0; i < sizeof(obj); i++)
    {
    MoveObject(obj[i], objpos[i][0], objpos[i][1], objpos[i][2], 2.00);
    }
I hope you understand what I mean.

Best regards,
Jesse
Reply
#3

you need a loop to move each object.
btw, the MoveObject() positions are absolute, not relative - the destination coordinates need to be calculated for each single object before moving it:
pawn Code:
new Float:TargetX,Float:TargetY,Float:TargetZ;
for(new id=0;id<178;id++)
{
    GetObjectPos(obj[id],TargetX,TargetY,TargetZ);
    TargetZ=TargetZ-50.0;
    MoveObject(obj[id], TargetX, TargetY, TargetZ, 2.00);
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)