[Tutorial] Axis and Angles/rotation of attached Objects
#1

In this tutorial I will try to explain the X, Y and Z coordinate system that SAMP uses for its attached objects, also I will cover the coordinates and angles which you need while attaching object to a player.

Contents
  • Player attached object coordinates
  • Player attached object angles
  • Map coordinates
Player Attached Object Coordinates

I've seen many people in the scripting discussion section asking about how to set values in SetPlayerAttachedObject, so this tutorial would explain it to them. Without wasting much time lets start.

So SetPlayerAttachedObject needs offset to be set for objects to be attached at the right position, it has foffsetX, foffsetY and foffsetZ. Offset decides distance of the object from center of the bone which you select.

foffsetX : Distance of Object on X axis from center of bone
foffsetY : Distance of Object on Y axis from center of bone
foffsetZ : Distance of Object on Z axis from center of bone

Now lets understand which one is X, Y and Z axis.
I'll use a money bag example here, money bag has ID:1550
If you just attach the money bag to spine(bone) without any other tweaks it gets attached like this

SetPlayerAttachedObject(playerid, 1, 1550, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1);



Now we need to adjust its position.
If you try setting foffsetX to 1, the object moves along X axis above the player, this means X axis is the vertical line in SAMP.

SetPlayerAttachedObject(playerid, 1, 1550, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1);



Similarly you can try with Y and Z axis.
We've found that X axis is the vertical axis, Y axis is the horizontal axis going through the player from his front to the back and Z axis goes horizontal through the player from left to right.

X, Y and Z axis of a player are shown below using ****** Sketchup.



This picture clearly shows the X, Y and Z axis of a player object, also the +ve and -ve directions are shown.

Player Attached Objects Angles

Now we will learn about the angles, you need to set them for every axis to turn or to rotate the object as you want.
We have 3 values
fRotX : Rotation about X axis
fRotY : Rotation about Y axis
fRotZ : Rotation about Z axis

Lets try inserting 90° in place of fRotX
SetPlayerAttachedObject(playerid, 1, 1550, 1, 0, 0, 0, 90, 0, 0, 1, 1, 1);
That will give you something like this.



Now try changing it to 180°, it will turns the object exactly upside down.

In the picture below i've shown the degrees of rotation along X axis. The original position at which the object spawns when you keep the fRotX field blank is 0 degrees. If you change it to 90°, it will rotate backwards and so on. You can even insert negative values here. Its similar to the geometry that you all have learnt in your schools, the maximum value here is 360 degrees.



You can try yourself the same rotation changes for Y and Z axis.

Here are the rotation degrees for Y axis:



And Z axis:



Note : You need to set the fScaleX, fScaleY and fScaleZ values greater than 0, if you keep these values zero the object will become invisible.
Settings the values of fScaleX, fScaleY and fScaleZ to 1 keeps the size of object original. You can change this value to any integer you like.

Map Coordinates

Well here's a small tip about map coordinates. Apart from player attached object axis the map axis are different.
X axis on the map refers the east and west directions while Y axis denote north-south directions. Z axis is for height.

Thats all for now! It was my first tutorial so correct me if I am wrong somewhere
Reply
#2

Amazing! Thank you ! :O
Reply
#3

Now thats what i call a tutorial. Great work. 11/10
You can't ask for more.
Reply
#4

Very nice one!!!
Reply
#5

Very useful, it can help many people that don't understand about theses positions.
Reply
#6

Very useful for setting Camera positions...etc.
Reply
#7

Thank u all for sweet comments :P
Reply
#8

I like your ****** Sketchup

Nice tutorial!

pawn Code:
This forum requires that you wait 60 seconds between posts. Please try again in 15 seconds.
Ah...
Reply
#9

Quote:

I like your ****** Sketchup
Nice tutorial!

Ty Well ****** Sketchup was the only way for me to show all the rotation angles And in addition, its Free!
Reply
#10

Awesomee!!
Reply
#11

Keep up the good work
Reply
#12

im using someones FS to place an object on a player but your tutorial sure made me understand it more
great examples i like the pictures
Reply
#13

This is what called as tutorial! it's really amazing! it's like how teachers explain on boards xD!
Reply
#14

Quote:
Originally Posted by bhaveshnande
View Post
You messed up the Z and X axis ^^.
Reply
#15

Very helpful topic, it is helping me alot !
Reply
#16

Quote:
Originally Posted by Lofti
View Post
Very helpful topic, it is helping me alot !
nice 4 year bump
Reply
#17

Would this work on non-attached objects?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)