[Tutorial] How to use rotation in MoveObject (0.3d)
#1

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

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);
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.
Reply
#2

Great work
Reply
#3

nice one Good job
Reply
#4

Thanks for the comments. Perhaps this will be of more use when 0.3d is released.
Reply
#5

Thanks for this tutorial. Will be useful in future.
Reply
#6

What about streamed object ?
Reply
#7

So this works for the orange-blue barrier?
Reply
#8

Quote:

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

Oh that's why it doesn't work ...

Thanks for the tut
Reply
#9

Thank you, i needed that.
Reply
#10

Quote:
Originally Posted by thimo
Посмотреть сообщение
So this works for the orange-blue barrier?
Same question, it works?
Reply


Forum Jump:


Users browsing this thread: 7 Guest(s)