- Home /
Getting particle to not damage the emitter parent
Well this is less a question on how to go about coding this as trying to figure out why it's not working. The emitter has a script with OnParticleCollision that calls a simple damage script:
Debug.Log("parent: " + transform.root.name + " other: " + other.name);
if(transform.root == other) {
Debug.Log("Self damage, ignoring...");
return;
}
shp.WeaponCollision(dmg);
The odd thing is that even though the first 'Debug.Log' line shows that the 'transform.root' and 'other' are the same gameObject (the names match up and there is only one of each type of prefab for testing purposes), the if statement is never true. Any ideas?
Hmm well I just tried using the GetInstanceID() function to see if the two GameObject's have the same ID. They don't. 2894 and 2898. I tried pinging some other things in the level with particles and their ID's are much further apart numerically.
Update: Solved it. I'll post.
Answer by MattA · Jun 28, 2010 at 09:24 AM
Ok, so what worked was:
(transform.root == other.transform.root)
These two have the same InstanceID's and the code works now.
You can accept your own answer so it won't show up under unanswered questions anymore.