I am using Unity 5 and I want to detect collisions between my player and the floor but I do not want physics to stop the rigid body passing over the floor. How do I do this?
Basically I want my player object to know what type of floor it is on but I obviously still want to walk over the floor.
You could add a layer for each type of floor and test what layer the player’s collider is touching.
public LayerMask lava;
public LayerMask grass;
private CircleCollider2D feet;
void Start(){
feet = GetComponent<CircleCollider2D>();
}
void Update(){
if (feet.isTouchingLayers(lava))
death...
if (feet.isTouchingLayers(grass))
that's ok
}