i have a collider that i have set as a trigger with the tag ‘march’ - when i walk into the trigger it triggers the event that i want to happen no matter what the tag is - i want it so that my event only happens if the trigger i walk into has the tag ‘march’ on it, is there any simple script to help me do this? this is what i thought would work but is clearly incorrect.
the parameter is just a name, it could be anything, it doesn’t matter. Just in the same way a variable can be given any name. you will need to check the tag on the collider.
now that i have the code working fine i thought everything would be working but that doesn’t seem to be the case, there are no errors but nothing is happening when i enter the trigger.
This is my full code for the script I’m working on:
public Canvas myCanvas;
void Start(){
myCanvas.enabled = false;//Your target for the refference
}
void OnTriggerEnter(Collider other){
if (other.tag == "March"){
myCanvas.enabled = true;
}
}
void OnTriggerExit(Collider other){
if (other.tag == "March"){
myCanvas.enabled = false;
}
}
}
i have the correct tag set too - the actual object that i have this script applied to is a sphere with the collider set to a trigger, do you have any idea as to what could be causing this?
Throw in a Debug.Log and see if the trigger methods are being called. If not its something is the scene set up. If they are being called it’s likely that the capitalisation and spelling on the tag name doesn’t match exactly.
for anyone else that stumbles upon this problem, it was a really silly mistake i had an object named march with the tag ‘march’ on it, and i was searching for a collision with the object with the tag march - so when my FPS entered there was nothing happening because my FPS didn’t have the tag ‘march’ on it - i had put it on my march object instead of my FPS! thanks for all the help everyone.