(Apologies if I’m posting this in the wrong forum!)
Hello,
Development on my game is going smoothly, but I ran into the following issue: I need to know whether the instantiated object is a child of another prefab.
So, to make this a bit more clear: I have a prefab called “Bullet Parent”, with a child called “Splattershot Bullet”. I instantiate this prefab during runtime. Upon colliding I need to be able to check whether the object I collided with is a child of “Bullet Parent”. It seems when I instantiate the Splattershot Bullet on its own, the parents gets lost.
This is the code I tried:
if (Physics.Raycast(new Ray(RayStart, RayDirection), out hit, _camDist)) {
if (PrefabUtility.GetPrefabObject((Object) hit.transform.parent) != _bullet) { //_bullet is the bullet parent I had assigned to the gameObject in the inspector
//Always triggers }}