Unknown identifier "other"

I tried to use other.CompareTag but just received an error saying that other is an unknown identifier? can anyone help me?

#pragma strict
var Slow = 0.5;
function Start () {

}

function Update () {
}

function OnTriggerStay(Bullet : Collider) 
{	//the "other" below this text is the one cauisng trouble it seems
if (other.CompareTag ("Bullet")) 
	{
	Time.timeScale = Slow;
	
	Time.fixedDeltaTime = 0.02 * Time.timeScale;
	}
}

function OnTriggerExit(Bullet : Collider)
{	//the "other" below this text is the one cauisng trouble it seems
if(other.CompareTag ("Bullet"))
	{
	Time.timeScale = 1;
	
	Time.fixedDeltaTime = 0.02 * Time.timeScale;
	}
}

[32218-inspector+1.png|32218]

Please post your actual, complete code.

i have posted the code now

Yes of course you are getting the error cause you didn't define the variable 'other'. You defined the Collider as 'Bullet'.

subhajit, try reading the comment i placed. it says that the other is the one causing trouble, the bullet define thingies had been there without causing trouble. but as soon as i added the "other" at the compare tag, it began causing trouble

That's what I said. You never defined 'other'. Try following tanoshimi's answer. We both are basically saying the same thing. :)

1 Answer

1

Replace

if(other.CompareTag ("Bullet"))

with

if(Bullet.CompareTag ("Bullet"))

sorry. that just seemed to make it not enter slow motion at all.

That's probably because the object entering the trigger isn't tagged "Bullet". Or you don't have a non-kinematic rigidbody attached.

what is the rigidbody supposed to be attached to?

At least one of the game objects involved in the collision.

well the "bullet" (actually a box that i used for testing) has a non kinematic rigid body.