- Home /
Question by
ThisIsIt · Jun 25, 2014 at 11:31 PM ·
mobilejoystickrotation axis
Converting 3D Rotation to 2D Rotation
private void PlayerRotation( float RotateFactor_Y, float RotateFactor_X, float RotateStrength )
{
Vector3 TargetDirection = new Vector3 ( RotateFactor_Y, 0f, RotateFactor_X );
Quaternion TargetRotation = Quaternion.LookRotation ( TargetDirection, Vector3.up );
Quaternion NewRotation = Quaternion.Lerp ( PlayerTransform.rotation, TargetRotation, ( RotateSpeed / 100f * RotateStrength ) * Time.deltaTime );
PlayerTransform.rotation = NewRotation;
}
Converting a 3D Joystick Script to work with a Top-Down 2D game to rotate on Z-Axis instead of Y-Axis.
Moving things around with no success, any suggestions?
I know it involves these 2 lines (+Vector2, not 3)
Vector3 TargetDirection = new Vector3 ( RotateFactor_Y, 0f, RotateFactor_X );
Quaternion TargetRotation = Quaternion.LookRotation ( TargetDirection, Vector3.up );
Comment