- Home /
question about invisible walls
so i created some invisible walls around parts of my game, but what annoys me is that rockets and stuff explode when it hits the wall. is there anyway that i can make it so only if a game object has a variable on it then it cant pass through, like:
if(cantGoThroughWall){
//some script here to make it not go through wall
}
or is there another way that i just dont know about?
Answer by cregox · Feb 18, 2010 at 11:02 PM
Maybe there's a simpler way. Have you tried Physics.IgnoreCollision?
It even has an example exactly about bullets:
// Instantiate a bullet and make it ignore collisions with this object.
var bulletPrefab : Transform;
function Start () {
var bullet = Instantiate (bulletPrefab);
Physics.IgnoreCollision(bullet.collider, collider);
}
Answer by Will · Feb 18, 2010 at 10:41 PM
If you look in the Scripting Reference there is Physics.IgnoreCollision or something similar that will do just that.
Sorry, when I started answering yours wasn't loaded on my page yet! :o