Maurize Posted January 18, 2012 Share Posted January 18, 2012 So I've created a other camera script.. But i want the arrow move with player but in front of him... I am not that good in math but I hope someone can help me out. local elementPed = createPed( 34, 2504.8, -1669.4, 13.4 ) local elementAim = createObject( 1318, 2504.8, -1669.4, 13.4, 0, 90, 0 ) -- arrow should work with player.. continue reading.. addEventHandler("onClientResourceStart", resourceRoot, function() showCursor( true, true ) setCameraTarget( getLocalPlayer(), elementPed ) fadeCamera( true, 1.0 ) bindKey( "w", "both", function() if ( getPedControlState( elementPed, "forwards" ) == true ) then setPedControlState( elementPed, "forwards", false ) else setPedControlState( elementPed, "forwards", true ) end end ) end ) addEventHandler( "onClientRender", getRootElement(), function() local sx, sy, wx, wy, wz = getCursorPosition" class="kw4">getCursorPosition" class="kw4">getCursorPosition" class="kw4">getCursorPosition() local px, py, pz = getElementPosition( elementPed ) local rz = - math.deg( math.atan2( px - wx, py - wy ) ) - 180 setCameraMatrix( px, py, pz + 20, px, py, pz ) if ( elementPed ) and ( elementAim ) then setPedCameraRotation( elementPed, rz ) setPedRotation( elementPed, rz ) setElementPosition( elementAim, px * rz / 180, py * rz / 180, pz ) -- get Cursor in front of Player not working.. setElementRotation( elementAim, 0, 90, rz ) -- get Cursor in rotation working.. else outputDebugString( "Error!" ) end end ) Link to comment
BriGhtx3 Posted January 18, 2012 Share Posted January 18, 2012 Why dont you attach it to the ped? Link to comment
Maurize Posted January 18, 2012 Author Share Posted January 18, 2012 yeah thanks, all i need ) 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