This script right here shows that the mouse has clicked said point, but has done nothing with the units.
using UnityEngine;
using System.Collections;
public class UnitDetection: MonoBehaviour
{
public GameObject flag;
public float distanceToMap = Mathf.Infinity;
public GameObject selection;
public Vector3 moveToPosition;
void Awake()
{
flag = GameObject.Find("_Flag");
}
void Update()
{
if (Input.GetMouseButtonDown(0))
{
CastRay();
}
}
public void CastRay()
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit, distanceToMap))
{
SelectableUnit su = hit.transform.GetComponent();
if (su != null && su.unitSide == SelectableUnit.UnitSide.friendly)
{
selection = hit.transform.gameObject;
}
if (su == null)
{
moveToPosition = hit.point;
moveToPosition.y = 0;
flag.transform.position = moveToPosition;
}
}
}
}
I have a seperate script that tells the units apart from friendly, nuetral, and enemy. So thats out of the way. Im just confused on what to do next. Help?
Sweet, actually that may work let me try it out first and ill see what happens. Thanks
– NoyesBoy93