denny199 Posted October 6, 2012 Share Posted October 6, 2012 (edited) 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 setElementPosition(localPlayer,abx,aby,abz) end function toggleAirBrake() air_brake = not air_brake or nil if air_brake then abx,aby,abz = getElementPosition(localPlayer) addEventHandler("onClientPreRender",root,putPlayerInPosition) else abx,aby,abz = nil removeEventHandler("onClientPreRender",root,putPlayerInPosition) end end bindKey("num_0","down",toggleAirBrake) Regards Danny Edited October 7, 2012 by Guest Link to comment
DiSaMe Posted October 6, 2012 Share Posted October 6, 2012 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: setPedRotation(localPlayer,math.deg(math.atan2(ctx,cty))) You may need to make the angle negative for this to work. Link to comment
denny199 Posted October 7, 2012 Author Share Posted October 7, 2012 Gheh gheh, I ment edited ;p But I see what you did there thanks Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now