Creating zone around player

Hello there. I’m new to unity. I’d like to create an invisible dome around the player when he collides with an enemy so that he and the enemy were inside it. It’s like a battle arena inside but limited by the dome itself. I understand that I need to trigger something on “OnCollisionEnter”. That just to spawn invisible dome like collider or something? Do you have any ideas?

It’s a bit perilous to go with slamming a collider down for such a thing. The reason is you would need to ensure all parts of the enemies don’t get “clipped” by the new collider, because if you’re using physics, it might send it flying.

Not only that but colliders really only work at their “skin,” and only one-way generally, eg., going INTO the collider. This means if you spawn a collider around you and I, neither of us are even going to know it happened. The physics system won’t check it if we’re deep inside it.

A better way might be to define a point in space as the “center of combat,” defining it at the moment combat begins.

From then on that point is given to all actors to tell them “Don’t go too far from this point” and then the combat can begin.

If you want OTHER enemies to not butt into the battle halfway along, then you can tell them “Don’t come with X distance of this center of combat point.” until the combat is over.

1 Like

So basically I need to create an empty gameObject, then link everyone to it and say for all actors something like “you can only be around this object’s radius”?

Sounds like a reasonable approach to begin with!

1 Like