Jump to content

Rotación del jugador según movimiento del mouse


Discipline

Recommended Posts

Posted

Hola, quisiera saber qué funciones o eventos puedo usar para cambiar la rotación del jugador según donde mires (o muevas el mouse). Básicamente cuando te estás moviendo y mueves el mouse tu rotación cambia, pero yo quisiera que funcione estando quieto. 

Posted (edited)

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
rsilex.png.0e6ad382b3fdc3cbe6390e3e847572c9.png

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