06.11.2011, 20:29
(
Последний раз редактировалось MP2; 31.01.2012 в 06:26.
)
MoveObject Rotation
by Mike
Introduction
I'm quite surprised nobody has made a tutorial on this yet!
Arguably the best feature in SA:MP 0.3d is; smooth object rotation. While it could be thought easy to implement, unless you know how it can be extremely confusing.
Function
First of all, let's take a look at the new parameters
MoveObject(objectid, Float:X, Float:Y, Float:Z, Float:Speed, Float:RotX = -1000.0, Float:RotY = -1000.0, Float:RotZ = -1000.0);
RotX, RotY and RotZ were added in 0.3d RC2.
The most important thing you need to know is that the rotation parameters are the FINAL ROTATION; meaning they are the rotation the object will be at when it stops moving. Thus, in order to achieve rotation you MUST move the object. Let's look at how to do that.
Usage
That code will move the object up by 0.0001 units (not even noticable) at a speed of 0.0001. It will take one second to complete, as the Z difference and speed are the same value, and the speed is in units per second. Here is a video of the above code in action:
[ame]http://www.youtube.com/watch?v=76MIkBZOyT0[/ame]
If you wish to make a barrier that opens and closes, when opening the barrier add 0.0001 to the Z height, and SUBTRACT 0.0001 when closing it. If you add 0.0001 each time it opens and closes, it's going to keep going up and up.
Summary
Thanks for reading. If you have any suggestions for improvements or additions to this tutorial please do let me know.
by Mike
Introduction
I'm quite surprised nobody has made a tutorial on this yet!
Arguably the best feature in SA:MP 0.3d is; smooth object rotation. While it could be thought easy to implement, unless you know how it can be extremely confusing.
Function
First of all, let's take a look at the new parameters
MoveObject(objectid, Float:X, Float:Y, Float:Z, Float:Speed, Float:RotX = -1000.0, Float:RotY = -1000.0, Float:RotZ = -1000.0);
RotX, RotY and RotZ were added in 0.3d RC2.
The most important thing you need to know is that the rotation parameters are the FINAL ROTATION; meaning they are the rotation the object will be at when it stops moving. Thus, in order to achieve rotation you MUST move the object. Let's look at how to do that.
Usage
pawn Код:
// Create the object at the center of San Andreas [just used for example]
new eg_obj = CreateObject(1234, 0.0, 0.0, 3.0, 0.0, 0.0, 0.0);
// Rotate the object by 180 degrees on the z axis
MoveObject(eg_obj, 0, 0, 3+0.0001, 0.0001, 0.0, 0.0, 180.0);
[ame]http://www.youtube.com/watch?v=76MIkBZOyT0[/ame]
If you wish to make a barrier that opens and closes, when opening the barrier add 0.0001 to the Z height, and SUBTRACT 0.0001 when closing it. If you add 0.0001 each time it opens and closes, it's going to keep going up and up.
Summary
Thanks for reading. If you have any suggestions for improvements or additions to this tutorial please do let me know.