- Home /
Immortal enemies when reanimated, or pooled game objects re-activated do not respond to collisions?
Ok I've just started adding a simple object pooling system to my game, bullets, enemies and powerups are recycled using a simple arraylist of active objects and a stack of used ones.
And it was looking like I had it working until.. the enemies became unkillable once they were recycled.
The recycling is simply a
Deactivation using
go.active = false / ridgidbody.velocity = Vector3.zero
Activation using
go.active = true
The bullets still work on new enemies and enemies not pooled but it looks like the problem is the enemies, bullets just bounce off them...
It looks like they are not responding to OnCollision events their internal game state looks good health OK update cycle working?
Answer by Bampf · Mar 01, 2011 at 12:27 PM
Double-check everything about their state, before and after, using the inspector. A simple example of what can go wrong: if you have a death animation or make the enemy into a ragdoll, a script might turn on is-kinematic or deactivate the rigidbody or collider.
If you can get two enemies on screen, one resurrected, then pause your game and compare them in the inspector, hopefully you'll see what's different.
I mentioned the physics components a the top because it sounds like you already checked over your own state variables like health, but of course you should check everything.
Note that you can use the Debug mode of the Inspector to see private variables.
Spot on Cheers, the problem was an exploding boolean flag...
Your answer
Follow this Question
Related Questions
How to get Direction after cueBall collide with any ball in unity3d ? 1 Answer
OnCollision using Orthello2D Framework is causing NullReferenceException 1 Answer
How do I use LayerMask to check collision? 1 Answer
i can see my objects collide but OnCollisionEnter never called c# 1 Answer
Collision Bug 0 Answers