Jump to content

Rotation help?


Recommended Posts

Hey there.

I've got a question about rotations because I don't know where to start.

I've edited a fly script, but now I want to set the players rotation on the camera target.

But I don't know where to start, and I don't know if it's posible.

My local script:

function putPlayerInPosition(timeslice) 
    local cx,cy,cz,ctx,cty,ctz = getCameraMatrix() 
    ctx,cty = ctx-cx,cty-cy 
    timeslice = timeslice*0.1 
    if getKeyState("]") then timeslice = timeslice*4 end 
    if getKeyState("[") then timeslice = timeslice*0.25 end 
    local mult = timeslice/math.sqrt(ctx*ctx+cty*cty) 
    ctx,cty = ctx*mult,cty*mult 
    if getKeyState("w") then abx,aby = abx+ctx,aby+cty end 
    if getKeyState("s") then abx,aby = abx-ctx,aby-cty end 
    if getKeyState("d") then abx,aby = abx+cty,aby-ctx end 
    if getKeyState("a") then abx,aby = abx-cty,aby+ctx end 
    if getKeyState("space") then abz = abz+timeslice end 
    if getKeyState("lshift") then abz = abz-timeslice end 
function toggleAirBrake() 
    air_brake = not air_brake or nil 
    if air_brake then 
        abx,aby,abz = getElementPosition(localPlayer) 
        abx,aby,abz = nil 

Regards Danny

Edited by Guest
Link to comment

You made it? Wow, I thought it was my airbrake script with modified controls... :)

You have to use arctangent function to get the camera rotation angle. Like this:


You may need to make the angle negative for this to work.

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...