Collider Problem

I have 3 fire orbs but I only can put 1 fire orb in the inspector. I tried “Destroy(gameObject);” but my FPS gets destroyed instead. Thus now when my FPS hit another fire orb, only the fire orb that is placed in the inspector is destroyed, not the fire orb that my FPS hit. Is it possible for my FPS to walk through a certain fire orb and only that fire orb that is being walked through is destroyed?

Below is my code:

var Fire: GameObject;

var otherScript : FPSWalker;
var increase = 5.0;
var temporarySpeed = 0.0; 
var speedBoostDuration = 4;
var nextActivationTime = 0.0;
private var timer = 0.0;
private var horizontalSpeed = Input.GetAxis("Horizontal");
private var verticalSpeed = Input.GetAxis("Vertical");
function Update()
{
 rigidbody.mass = 0.1;
 var otherScript = GetComponent(FPSWalker);
 
}
function OnControllerColliderHit (collisionObject: ControllerColliderHit)
{ 
 if(collisionObject.gameObject.name == "Fire" && Time.time > nextActivationTime) 
 { 
  
  nextActivationTime = Time.time + speedBoostDuration;
  
  for (var i = 0; i <= 6; i++)
  {
   temporarySpeed = otherScript.speed +increase;
   Destroy(Fire, 0.0); 
   yield WaitForSeconds(3);
   temporarySpeed = otherScript.speed;
  }
  
  rigidbody.AddTorque(Vector3(0,horizontalSpeed,verticalSpeed) * 10); 
  rigidbody.AddForce (Vector3(temporarySpeed,0,0));
  
  
  
 } 
 
 
}

Thank you in advance! :slight_smile:

Just change the Destroy function and move it out of the for loop (whoose function I sincerely didn’t understand!):

  nextActivationTime = Time.time + speedBoostDuration;
  Destroy(collisionObject.gameObject); // <-- moved here
  for (var i = 0; i <= 6; i++)
  {
   temporarySpeed = otherScript.speed +increase;
   yield WaitForSeconds(3);
   temporarySpeed = otherScript.speed;
  }

This will destroy the object hit by the character if its name is “Fire”. You can forget about the Fire variable at the beginning of the script, since the character will destroy any “Fire” object it collides with.