- Home /
Collider not working...
In my game I have a player, and 4 walls. The player moves around the screen until touching one of the walls. The walls move as well as the player.
I have IsTrigger set on all four walls, and the following code applied to all four walls, but not the player:
function OnTriggerEnter (other : Collider) {
Destroy(other.gameObject);
print("Code ran.");
}
The player has a rigidbody, but the walls don't.
When the walls hit the player, it sometimes works.
If the player stays still (and hasn't moved throughout the whole game), the wall will just go straight through the player. However if the player moves, the player will be destroyed. What is causing the wall to go straight through the player?
I think it is due to the updates of physics, I think you need to set you're players rigidbody to continuous dynamic because if a physics object stays still, they kinda turn off, unless they are continuously dynamic which keeps them updating.
or add another boxcollider with the is trigger unchecked
Your answer
Follow this Question
Related Questions
col.gameObject.layer is not working 1 Answer
Something wrong with destroying script 0 Answers
Enable objects to enter the trigger 2 Answers
Destroying objects within collision 1 Answer
Collider not detecting trigger 1 Answer