Joystick help

.

Math!

For the first one, you’d clamp the x/y values to the distance formula. (distance = sqrt(x^2 + y^2))… do algebra to solve for what you need.

Answer to your second question (in c#) : (halt is the transform of my player)

		if(rightJoystick.position != Vector2.zero){
			float facing = Mathf.Atan2(rightJoystick.position.x, rightJoystick.position.y) * Mathf.Rad2Deg+270.0f;
			displacement = halt.eulerAngles;
			displacement.y = facing;
			halt.eulerAngles = displacement;
			if(weapon != null){
				weapon.Shoot();
			}
		}

.