2
\$\begingroup\$

I have created a trigger zone to make sure that only only gameobject passes through it at a time. The moment the gameobject1 entered the trigger zone, it is given a particular tag but I am not how to stop other gameobjects from entering the zone. Is it possible to have two trigger colliders attached to a same object like an outer and inner trigger such that only one gameobject is allowed to pass through the inner one while all other gameobjects wait at the outer one.

\$\endgroup\$

3 Answers 3

2
\$\begingroup\$

If you need to have multiple trigger zones around your GameObject, you can add empty GameObjects as children of that GameObject and add the colliders to those children. You can then assign different tags to those child objects to be able to differentiate between outer and inner trigger zones in your code.

enter image description here

\$\endgroup\$
1
\$\begingroup\$

You can try updating the tag of your trigger object and in the other gameobjects OnTriggerEnter set the move speed to 0 and the position to the position of your trigger.

\$\endgroup\$
1
\$\begingroup\$

I would have made this trigger a solid collider and edit the Layer Collision Matrix (found in Edit>Project Settings>Physics) to make it not interact with gameObject1, given a special layer.

More info on Layer Collision Matrix: https://docs.unity3d.com/Manual/LayerBasedCollision.html

\$\endgroup\$
1
  • \$\begingroup\$ You can also use the IgnoreCollision method to selectively exclude particular colliders on a layer that should otherwise collide. \$\endgroup\$
    – DMGregory
    Commented May 14, 2018 at 13:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .