Edited
Nevermind, I’m stupid. The script is supposed to say:
function OnTriggerEnter (other : Collider)
and now it works just fine.
I’m trying to have a switch that turns on and off music when the player touches the collision box. I’m using a simple boolean script that will be attached to each of the collision boxes. The box is set to “Is Trigger” and I’m using the standard FPS controller. However, the player walks right through the box and the boolean is never set to true. I’ve tried many variations with no success. I’ve changed the function to: function OnTriggerEnter (other : Collision) and Unity gives me this error:
Script error: OnTriggerEnter
This message parameter has to be of type: Collider
The message will be ignored.
I’ve made my own player character from scratch, I’ve added and removed rigidbodies and changed the script in various ways but I just can’t get the collision to work. Any ideas what I’m doing wrong?
var myCheck : boolean = false;
var music : AudioClip;
function Update ()
{
if(myCheck == true)
{
audio.volume = 1;
print("Music ON");
}
else
{
audio.volume = 0;
print("Music OFF");
}
}
function OnCollisionEnter (other : Collision)
{
if(other.gameObject.tag == "Player" myCheck == true)
{
myCheck = false;
}
else if(other.gameObject.tag == "Player" myCheck == false)
{
myCheck = true;
}
}