Wrong Trigger causes action to run,Multiple Triggers cause the same event
Hello Guys, I have a Little Problem with a Scene, where I have two VEhicles that the Player can enter. Each Vehicle has a Trigger and a script that uses the Trigger of the Vehicle and activates the Camera of the Vehicle. The Problem is: When I enter the trigger of the first vehicle, the camera of the second vehicle gets activated too. My Script:
void OnTriggerEnter(Collider other)
{
if (other.transform.name == "Trigger1")
{
inTrigger_p = true;
character = other.gameObject;
}
}
Other Things I tried:
if (other.name == "Trigger1") if (other.transform.tag == "Trigger1") if (other.tag == "Trigger1") if (other.CompareTag("Trigger1"))
The trigger´s name is Trigger1 and its tag is also Trigger1.
Has anyone an Idea what my mistake could be?,Hello guys, I have set up a Scene, where the user can enter multiple Vehicles. My Problem is now, that if the player enters the trigger of the first vehicle, the script of the second vehicle thinks, that the Player entered the trigger of the second vehicle. Script:
void OnTriggerEnter(Collider other) { if (other.transform.name == "Trigger1") { inTrigger1 = true; character = other.gameObject; } }
The script of the second vehicle, but instead of "Trigger1" I wrote "Triger2"
I tried it with: other.name == "Trigger1" other.tag == "Trigger1" other.transform.tag="Trigger1" other.compareTag("Trigger")
Has anyone an idea what my mistake could be?