I have a question. I have 4 objects on the screen and a projectile as in the picture below. image source
When I click on an object in the 4 projectile it changes position indicating to the object I clicked on. This is the code used but it does not work.
public GameObject Tun;
public GameObject[] robotColliders;
public GameObject[] Robots;
foreach(GameObject coll in robotColliders)
{
coll.GetOrAddComponent<MouseEventSystem>().MouseEvent += SetGeometricFigure;
}
private void SetGeometricFigure(GameObject target, MouseEventType type)
{
if(type == MouseEventType.CLICK)
{
Debug.Log("Clicked");
int targetIndex = System.Array.IndexOf(robotColliders, target);
Tun.transform.DORotate(Robots[targetIndex].transform.position, 2f, RotateMode.FastBeyond360).SetEase(Ease.Linear);
}
}
I was thinking about using the component DORotate(), But it does not work anyway. Does anyone know how to fix this problem?