SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Tutorials

Reply
 
Thread Tools Display Modes
Old 06/11/2011, 08:29 PM   #1
MP2
Godfather
 
MP2's Avatar
 
Join Date: Jan 2011
Location: England
Posts: 6,421
Reputation: 973
Default How to use rotation in MoveObject (0.3d)

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

Code:
// 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.

Last edited by MP2; 31/01/2012 at 06:26 AM.
MP2 is offline   Reply With Quote
Old 07/11/2011, 05:13 PM   #2
Mr_Scripter
Huge Clucker
 
Mr_Scripter's Avatar
 
Join Date: Mar 2011
Posts: 397
Reputation: 33
Default Re: How to use rotation in MoveObject (0.3d)

Great work
__________________

Current Project: Stunt-DM-Drift-Race.
Done: 0%
Looking for 2Mappers... Pm Me

Gamemodes
SanAndreas Team DeathMatch Gamemode-4 hours work
Mr_Scripter is offline   Reply With Quote
Old 07/11/2011, 05:26 PM   #3
System64
Gangsta
 
System64's Avatar
 
Join Date: May 2011
Location: Zadar, Croatia
Posts: 940
Reputation: 143
Default Re: How to use rotation in MoveObject (0.3d)

nice one Good job
__________________
All my works
I left SA:MP! Maybe once I start scripting again but now I'm based on web programming
Soon, I'll buy domain system32.com.hr but for now you can contact me on LogoOff or on my Youtube channel!
System64 is offline   Reply With Quote
Old 19/11/2011, 02:04 AM   #4
MP2
Godfather
 
MP2's Avatar
 
Join Date: Jan 2011
Location: England
Posts: 6,421
Reputation: 973
Default Re: How to use rotation in MoveObject (0.3d)

Thanks for the comments. Perhaps this will be of more use when 0.3d is released.
MP2 is offline   Reply With Quote
Old 19/11/2011, 05:27 PM   #5
Astralis
Guest
 
Posts: n/a
Default Re: How to use rotation in MoveObject (0.3d)

Thanks for this tutorial. Will be useful in future.
  Reply With Quote
Old 23/11/2011, 03:08 AM   #6
xinix000
Big Clucker
 
Join Date: May 2010
Posts: 104
Reputation: 0
Default Re: How to use rotation in MoveObject (0.3d)

What about streamed object ?
xinix000 is offline   Reply With Quote
Old 06/12/2011, 03:14 PM   #7
thimo
High-roller
 
thimo's Avatar
 
Join Date: Jan 2009
Location: Netherlands
Posts: 1,146
Reputation: 24
Default Re: How to use rotation in MoveObject (0.3d)

So this works for the orange-blue barrier?
thimo is offline   Reply With Quote
Old 06/12/2011, 03:21 PM   #8
[email protected]
High-roller
 
Michael@Belgium's Avatar
 
Join Date: Dec 2010
Location: Belgium
Posts: 3,035
Reputation: 1001
Default Re: How to use rotation in MoveObject (0.3d)

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
__________________
Mah Github. - Mah Youtube
Interested in a full featured and cheap derby gamemode or need host-tab ? Contact me on skype: michael.belgium
Michael@Belgium is offline   Reply With Quote
Old 06/12/2011, 03:43 PM   #9
xNn
Little Clucker
 
Join Date: Jul 2009
Posts: 21
Reputation: 0
Thumbs up Re: How to use rotation in MoveObject (0.3d)

Thank you, i needed that.
xNn is offline   Reply With Quote
Old 12/12/2011, 02:14 PM   #10
wups
High-roller
 
wups's Avatar
 
Join Date: Apr 2010
Location: Lithuania
Posts: 1,254
Reputation: 137
Default Re: How to use rotation in MoveObject (0.3d)

Thanks, I find this very useful!
wups is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
MoveObject with rotation BGMike Help Archive 1 26/06/2011 09:45 AM


All times are GMT. The time now is 08:08 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.