I have been able to select enemies with the below raycast script, however when each enemy is selected, I want to give the user feedback which enemy is selected. (i.e. a Ring around the base of the enemy) I have been unable to create, find a solution, so asking for help / ideas to keep me going.
Currently I believe that enabling the mesh renderer on the quad will be the easiest way to do this, but I am disabling the parents renderer instead of the quad Child.
function Update()
{
if (Input.GetMouseButtonDown(1)) //Right CLick
{
var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
var hit : RaycastHit;
if (Physics.Raycast (ray, hit, 100))
{
Debug.DrawLine (ray.origin, hit.point);
Debug.Log (hit.collider.gameObject.name);
var es = hit.collider.gameObject.GetComponentInChildren(MeshRenderer);
es.enabled = false;
}
}
}
If you think there is a better way to do this, please let me know, or point me in the right direction.
Image of Quad Location Setup (As a Child under the Cube GameObject)
![alt text][1]
[1]: /storage/temp/19999-circlequadsetup.jpg
↧