So im creating a 2d cursor shooter, and the players arm/gun rotates towards the cursor, but it look’s really odd because the Character itself does not flip towards the mouse (i dont want it rotating towards it, just a simple left/right flip)
using UnityEngine;
using System.Collections;
public class Spriteflip : MonoBehaviour {
public int rotationOffset = 90;
public Transform target;
Camera camera;
private Transform playerScreenPoint= Camera.main.WorldToScreenPoint(player.transform.position);
void Start() {
camera = GetComponent<Camera>();
}
// Update is called once per frame
void Update (){
if(mouse.x < playerScreenPoint.x) {
Flip()
} else {
Flip()
}
private void Flip()
{
// Switch the way the player is labelled as facing.
m_FacingRight = !m_FacingRight;
// Multiply the player's x local scale by -1.
Vector3 theScale = playerGraphics.localScale;
theScale.x *= -1;
playerGraphics.localScale = theScale;
}
}