Hey guys,
Working on a game that involves a ball hitting a button and having the button activate something. I am already familiar with triggers.
What I want is for the ball to hit the button (have the ball enter the collider) and the have that trigger a wall to move so the player can advance. I have it all set up, but when the ball enters the collider, nothing happens.
I already have successfully used triggers earlier in this project to trigger the end of a level, so I think it should be working.
Here is the code that is applied to the button:
#pragma strict
var floor: GameObject;
var triggered: boolean = false;
var target: Collider;
function Start () {
}
function OnTriggerEnter(collision: Collider) {
if(collision != target) {
return;
}
triggered = true;
//if(triggered == true) {
//for(var i: int = 0.5455484; i < 20; i++) {
floor.transform.position = Vector3(3.313264, 20.545548, -0.07298398);
//}
//}
}
function Update() {
}
I have already tried putting the if statement in the update function so that it will always check, and that didn’t work.
Specs:
Ball:
-Sphere Mesh Filter
-Sphere Collider (checked)
-isTrigger = false
-Mesh Renderer (checked)
-RigidBody (checked)
Button:
-Sphere Mesh Filter
-Mesh Renderer (checked)
-Sphere Collider (checked)
-isTrigger = true
Am I doing something wrong? Am I missing information?
Thanks a lot guys, you’ve already been a huge help to me.
-Silent