I have a player which is a Fish swimming left and right. Everytime i click in a position, the fish will follow to where I am clicking. So if i click on the further right screen space, the fish face right and follow to the right screen. I have done almost everything right with click to move. The only problem is when I click on the left screen space, the player does move to the left but it is still facing right. So how do i make it face left when i click left and face right when i click right. I don’t need it to face anywhere else but left and right. pls help
here’s my script:
void Update()
{
if((grounded || !doubleJump) && Input.GetMouseButtonDown(0))
{
target = Camera.main.ScreenToWorldPoint (Input.mousePosition);
anim.SetBool ("Ground", false);
GetComponent<Rigidbody2D>().AddForce(new Vector2(0, jumpForce));
target.z = transform.position.z;
}
transform.position = Vector3.MoveTowards(transform.position, target, speed * Time.deltaTime);