- Home /
Some colliders work, some don't...
I have a bit of a conundrum with my colliders, so I am appealing for suggestions as to what could be happening. I have a zombie model in my scene, that follows and then melee attacks the player (top down 3rd person). The zombie has a box collider on the model to take damage, and for the melee damage to the player, I have placed a sphere collider on each hand which are triggers. The player cannot damage the zombie. The zombie model and the sphere colliders are on different layers, and to avoid collision conflict, I keep them separated with the physics matrix in edit>project>physics, and everything works fine.
I also have sentry guns that can kill the zombies if they come within range, and this also works fine. However, if I duplicate the zombie model in the scene, everything still works regarding the player damage, but they can no longer be killed by the sentry guns. I have narrowed the cause down to the 2 spherical trigger colliders, because if I turn the colliders off in the inspector, the zombie gets gunned down by the sentry guns as they should, but obviously I can't deal any damage to the player with the colliders turned off.
My question is, I guess, what could possibly change between an original model in a scene and its' duplicate, that would suddenly render the sentry gun damage useless because of the sphere colliders? The damage script on the bullets is a basic On Collision apply damage script, but this seems to be a moot point, seeing as how with the original zombie model everything works perfectly...it's only the duplicate that has the problem. Sorry for the text wall, and thanks for any/all replies.
$$anonymous$$aybe some pieces of code would be fine.
Do you check the name in the "OnCollision"$$anonymous$$ethod? If so, maybe the original has the name "Zombie" and the duplicate the name "Zombie(Clone)" or something like that?
When you damage a duplicate, does the damage occur to the original? A straight duplicate would also duplicate tags and names.
Also what are the sphere colliders a trigger for?
$$anonymous$$aybe, ins$$anonymous$$d of duplicating the Zombie model, set up a script to use Instantiate, which makes a clone with which you can separate names and still use the same tags.
Thank you for the responses. @ reppiz01 - one of the reasons I used the physics setting was to avoid the possibility that I could be getting an incorrect name in an ignore collision script on the duplicate, so this isn't the problem, though I will check again - the bullets OnCollision script specifies no particular name, its a generic whatever you run into script.
@ meat - no, the original does not take damage if the duplicate does, and the spheres are triggers for a damage script on the player toon - better to have them as triggers than colliders I thought to avoid any collision issues with their own box collider, and like I say in the post, the system works great, except for when I duplicate the model - this inability to duplicate also makes creating a prefab pretty much impossible, which is what bothers me the most (apart from it not working lol)...and I will try you suggestion of duplicating via a script.
Apologies for late reply, I'm on the other side of the planet :)