#Weird gameObject.SetActive behavior

1 messages · Page 1 of 1 (latest)

keen hill
#

I mean, I would need some more context probably, but it seems like it could be hitting itself with the explosion, therefore infinitely alternating between calling TakeDamage on itself, which then calls the Die function (which then calls TakeDamage on itself, etc)

#

that is just a guess though, you would need to show some more code

#

The reason that moving the SetActive false to the end would cause the issue is because the OverlapSphere wouldn't grab disabled colliders

#

so disabling it in the beginning causes it to not hit itself (resolves the issue)

#

whereas putting it at the end would allow it to hit itself (causes the issue)