Answer the question
In order to leave comments, you need to log in
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?
The first object that does not control is client 1
The second object that controls is client 1
Answer the question
In order to leave comments, you need to log in
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(); //вызываем для текущего объекта какой-либо метод
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question