D
D
Denis Mashanov2017-02-14 11:17:09
C++ / C#
Denis Mashanov, 2017-02-14 11:17:09

How to solve the problem with Trigger?

Good afternoon everyone. I have a problem with object triggers, please help me to solve it. Client 2 - 1 enters 2, the first client is triggered. At the same time,
Client 1 - 1 enters 2, the trigger does not work for 2.
In client 1, object 2 has a trigger enabled and has an OnTriggerEnter event, and in client 2, object 1 also has a trigger enabled and has an OnTriggerEnter event.
The question is why? I have one more problem observed, the trigger fires only once, that is, the event fires only once, if I enter again, it is already silent. How to solve these 2 problems?
8594111f75984ffd8e1e3b91e215d706.png
The first object that does not control is client 1
3b00791fa8b04e8c9275c073fc52394f.png
The second object that controls is client 1
1c9da4d1686545e6b9c515dad512bedf.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
TheTalion, 2017-02-14
@LoneRay

OnTriggerEnter is called when another collider enters the collider (labeled isTrigger). In order to trigger events for all objects, you need to hang scripts with OnTriggerEnter for all objects, or call any methods by type:

OnTriggerEnter(Collider _col)
{
if (_col.tag == "name")
{
_col.gameObject.GetComponent<Script>().useThisMetod();//для объекта, с которым произошло столкновение вызываем метод
useThisMetod(); //вызываем для текущего объекта какой-либо метод
}
}

Also, in order for the trigger to fire constantly while you are in it, use OnTriggerStay()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question