I’m working on an Endless runner and I have a wall to destroy(later on deactivate instead of destroy…)the gameobjects the player doesn’t collect, but I’m having trouble getting my “Coins” to be destroyed when hitting my “Wall”…I have a runner script that is working perfectly. I’ve even used that script on my “Wall”, but it will only destroy the coins and register as an OnTriggerEnter. If you toggle isTrigger on the wall while the scene is playing or if the wall is moving with some sort of force. If I manually move the wall up and down in the editor while the scene is playing. It will trigger the function. Can the OnTriggerEnter be used on static(non-moving) objects?
Here’s the setup:
- Coin isTrigger
- Coin is Tagged with “coin”
- Wall has RigidBody
Wall Script:
function OnTriggerEnter (other : Collider){
if(other.tag == "coin"){
Destroy(other.gameObject);
}
}
Coin Script:
function Update () {
transform.Rotate(Vector3.left * Time.deltaTime * 75);
}
(An empty game object is over each coin to move the coin forward. Otherwise it moves in a circle because of the transform.Rotate above. I’ll find a better way for this later, but i’ve tested it without the parent and it still doesn’t trigger the function.)
Hopefully I didn’t leave anything out. Please don’t hesitate to ask for more details