Im working on a game where you play as both an angel and a demon. They each have their own set of powers. The demons power consit of destroying things and phasing through walls. Im not the strongest programmer. This game is completely in First Person. So Im wondering how I would program the phasing through walls.
Assuming you have colliders and rigidbodies on the players and the walls, just disable the rigidbody collision: Unity - Scripting API: Rigidbody.detectCollisions (untested)
you could create new scenes which you play as the angel and demon. For the demon scenes just get rid of the box collider for walls you want the player to go through
I would create a Boolean, if it equals to true its an angel, else its a demon, if your Boolean equals to true (angel mode), then you just disable the wall colliders.
//just a simple example
var playerMode: boolean;
var wallCollider: Collider;
function Update(){
if(playerMode == true){ //if angel
wallCollider.enabled = false; //disable wall
}else{wallCollider.enabled = true;}//if demon, enable them
}
Hope it helps, good luck.
Hope this help Set wall collision layer as wall, flour - flour, and demon - demon.
if (demon.CanWalkThroughtWalls)
Physics.IgnoreCollision(demon.collider, wall.collider);
else
Physics.IgnoreCollision(demon.collider, wall.collider, false);
Or something like this. Don’t remember now