Jump to content

Rotación del jugador según movimiento del mouse


Discipline

Recommended Posts

No he tenido tiempo para probarlo pero esa es la idea supongo que debería de funcionar. Se puede usar o bien onClientRender con la funcion renderMove o bien usando onClientMouseMove o algo asi

function findRotation( x1, y1, x2, y2 ) 
	local t = -math.deg( math.atan2( x2 - x1, y2 - y1 ) )
	return t < 0 and t + 360 or t
end

function renderMove()
	local _, _, _, x, y, z = getCameraMatrix ();
	local pX, pY, pZ = getElementPosition(localPlayer);
	local angle = findRotation(pX, pY, pZ, x, y, z);
	setElementRotation(localPlayer, 0, 0, angle);
end
Edited by Arsilex
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...