I have a central object which is rotating around itself. I also got an arrow which is following the central rotation. If I click on the screen the rotation changes to the opposite direction.
I want the arrow object to flip around so it would point to the rotation direction. How can I do this?
My script so far:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CenterRotation : MonoBehaviour
{
public int direction= 1;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
transform.Rotate(new Vector3(0, 0, direction), Space.Self);
if (Input.GetMouseButtonDown(0))
{
{
if (direction> 0)
{
direction= -1;
Debug.Log("Changes direction!");
}
else
{
direction= 1;
Debug.Log("Normal rotation!");
}
}
}
}
}
I attached pictures to the question just to be clear.
Thanks!