25.06.2012, 01:32
Bit ironic seeing as how I created the first and possibly only tutorial for this, but I need help with rotating objects with MoveObject.
As you should know (if you don't; stop reading you're wasting both mine and your own time), to rotate objects you have to move them, as the rotation parameters in MoveObject are the 'final rotation' - the rotation the object will be in at the end of movement.
The problem I have is I am trying to make a RotateObject(objectid, rx, ry, rz, speed) function by moving the object down by 0.001 with SetObjectPos then moving it to the original Z position through MoveObject, thus not affecting the position of the object.
It works fine but the problem is, if the rotation if half way through and I rotate it back, it takes twice as long.
This is the current code I have:
Is it just not syncing fast enough or what? I tried StopObject() before also.
I'm thinking an alternative could be to swap it around. Move it up by 0.0001 with MoveObject then move down by 0.0001 in OnObjectMoved, but that'd require variables and this method has no variables which is obviously better. Shame it doesn't work though.
Any ideas?
EDIT: Thinking about it now, using OnObjectMoved may be a better idea after all, as this method may lead to the object rising up (though not by much) for example say you have a barrier at the SFPD and you have a lot of cops coming in and out of it, and as it's closing someone re-opens it, it will be lowered by 0.0001 and then moved up to +0.0001, causing it to be higher than it was originally. So I may do that instead.
As you should know (if you don't; stop reading you're wasting both mine and your own time), to rotate objects you have to move them, as the rotation parameters in MoveObject are the 'final rotation' - the rotation the object will be in at the end of movement.
The problem I have is I am trying to make a RotateObject(objectid, rx, ry, rz, speed) function by moving the object down by 0.001 with SetObjectPos then moving it to the original Z position through MoveObject, thus not affecting the position of the object.
It works fine but the problem is, if the rotation if half way through and I rotate it back, it takes twice as long.
This is the current code I have:
pawn Код:
stock RotateObject(objectid, Float:rx, Float:ry, Float:rz, Float:speed)
{
if(!IsValidObject(objectid)) return 0;
speed = 0.0001 * speed;
new Float:x, Float:y, Float:z;
GetObjectPos(objectid, x, y, z);
SetObjectPos(objectid, x, y, z-0.0001);
MoveObject(objectid, x, y, z, speed, rx, ry, rz);
return 1;
}
I'm thinking an alternative could be to swap it around. Move it up by 0.0001 with MoveObject then move down by 0.0001 in OnObjectMoved, but that'd require variables and this method has no variables which is obviously better. Shame it doesn't work though.
Any ideas?
EDIT: Thinking about it now, using OnObjectMoved may be a better idea after all, as this method may lead to the object rising up (though not by much) for example say you have a barrier at the SFPD and you have a lot of cops coming in and out of it, and as it's closing someone re-opens it, it will be lowered by 0.0001 and then moved up to +0.0001, causing it to be higher than it was originally. So I may do that instead.