void OnTriggerEnter(Collider other) { PlayerStateController player = other.GetComponentInParent <PlayerStateController>(); Loot loot = player?.GetComponentInChildren <Loot>(); if (!loot) { return; } loot.Absorb(); // Add VFX if (GetIdVFX(player.transform) == -1) // Check that we have not added one already { Transform ray = Instantiate(drainRay, mainCrystal.transform.position, mainCrystal.transform.rotation).transform; ray.SetParent(mainCrystal); // 1 is the index of the first child (after the parent itself) Transform target = ray.GetComponentsInChildren <Transform>()[1]; target.SetParent(loot.transform); target.localPosition = Vector3.zero; rays.Add(new Ray(ray, target)); loot.target = target; } }