# How to get the rotation!?

## Recommended Posts

Good evening fellows,

Recently, I've been trying to find the rotation of one part or side of a random object but I couldn't really find the function or the way to do so therefore I'm stuck.

If you did not understand the idea, I'll explain it below;

A cube is made of 6 sides or faces, generally in MTA if we have an object with a shape of cube or any other shape, we can get its rotation by just using getElementRotation. But, if we want to get the rotation of one face of its faces it is only possible with couple mathmatic calculations which is a bit complicated when this object is on the form of a cube, therefore it would be more complex if it isn't a cube.

A simpler instance, If I was standing infront of a wall, and this wall is one side of a house, this means that house rotation isn't certainly the wall's rotation, but thier rotation is of course related to each other, How will I be able to get the rotation of the wall which is one face or side of a house/building?

If you did not understand, I may try to give clearer examples. However, if you got my point, do you have any ideas to share?

I guess you're looking for processLineOfSight. However, it does not return the rotation directly so you have to calculate it from the returned normal vector.

• 3
• Moderators

I am not sure if you are asking a simple question or a hard question. It might be handy to add a screenshot.

If it is a simple question, than this is one of the answers to it:

```-- 90 (1/4), 180 (1/2), 270 (3/4), 360 round and round and round...
local rotationAdjustments = {xr = 90, yr = -90, zr = 0}
function getWallRotation (element)
local xr,yr,zr = getElementRotation (element)
end```

Simple add or subtract(minus value) rotations values of the mta rotation.

Example:

`local awesomeRotationX, awesomeRotationY, awesomeRotationZ = getWallRotation(element)`

As @Jusonex said with processlineOfSign, which will return the exact rotation if used correctly. But you can also play a little bit with it manually. It doesn't have to be pixel perfect!!

Edited by IIYAMA
• 1
On 10/03/2017 at 16:58, Jusonex said:

I guess you're looking for processLineOfSight. However, it does not return the rotation directly so you have to calculate it from the returned normal vector.

@Jusonex yeah, that's exactly what I wanted. the normal vector, since Its always perpendicular to the surface. Anyway, the normalx, normaly and normalz values are rotations or coordinations?

• Moderators

They are the direction vector of how the line hits on the object.

If you hit the object it will return a vector that represents how that part of the object is facing a direction.

I am using this function to determine how custom bullet holes are placed on to the objects in the world.

If the vector returns (0 x,0 y, 1 z) than the bullet holes would be facing up. Which is most likely the case when you hit the flat ground. (not sure if you have to invert the vector, I haven't used this function for a while)

Just now, IIYAMA said:

They are the direction vector of how the line hits on the object.

If you hit the object it will return a vector that represents how that part of the object is facing a direction.

I am using this function to determine how custom bullet holes are placed on to the objects in the world.

If the vector returns (0 x,0 y, 1 z) than the bullet holes would be facing up. Which is most likely the case when you hit the flat ground. (not sure if you have to invert the vector, I haven't used this function for a while)

Yeah, bullet holes is what i am trying to script right here. But anyway, something is still wrong with the directions... I will be trying to find out what is it.

problem solved! thanks for your contribution mates.

## Create an account

Register a new account