Jump to content

Rotate element to an other element


Gordon_G

Recommended Posts

Hello ! I'm trying to do a script, and I need to turn the player, to a point.

I know it will be a mathematical function, I started like this but it's not working :

 

function turn(source)
local x,y,z = getElementPosition(source) 
local x1,y1,z1 = -2004.1025390625,146.181640625,27.5390625
local Player_A = getDistanceBetweenPoints2D(x,y,0,0)
local A_point = getDistanceBetweenPoints2D(0,0,x1,y1)
print(A_point)
print(Player_A)
local rot = math.deg(math.atan(Player_A/A_point))
print(rot)
setElementRotation(source,0,0,rot)
end
addCommandHandler("turn",turn)

Could someone help me ? Thanks ! 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...