I have a raycast which is set to trigger when on a certain object. It does this by detecting the transform name.
However I now need to find out if the transform I have detected is a child of a specific parent transform.
[Updated]Is there a way to get the Root Parents Name of the Transform my RayCast Hit?
Here is my code so far:
if(Physics.Raycast(transform.position, forward, hit, rayCastRange)){
if(hit.transform.name == "AttackerTowPoint")
{
//Find out if hit.transform is a child of a GameObject called "Attacker"
}
}