hi!
i have the following raycast, that sets the collider that was hit as the target:
but i dont want to be the target the collider. i want it to be the parent gameobject of the collider.
i have tried to do it with one of the outcommented lines. but they dont work.
public GameObject target;
void FindTarget ()
{
RaycastHit hit;
Ray ray = new Ray();
ray.origin = transform.position;
ray.direction = Vector3.forward;
if (Physics.Raycast(ray, out hit, maxRange))
{
Debug.DrawLine(ray.origin, hit.point);
target = hit.collider.gameObject;
//target = target.parent;
//target = target.gameObject;
}
}
}