MrHero
1
Hello,
I’m trying to make a floor which slows, damage, etc. the player when the player moves on top of it…
my player is a Rigidbody with 2D collision on, and the floor should be without collision …
im not sure how would i communicate between the two object since one has a collision and the other is not, so i though maybe there is a way to check if two rigidbodies are on top of each other?
im quit not sure how would i check this condition tried to search online but i didn’t know what should i search for so… 
sorry if this is very basic but yeh ^^
Best Regards,
MrHero
You can put a box collider on the floor and check the is Trigger option, make sure the trigger area is high enough so that it can detect the player, add a tag “Player” to the player character, then use something like this:
public int health = 100;
public float speed = 20.0f;
public bool isIn = false;
void Update(){
if(isIn)
health--;
speed = speed/2;
}
void OnTriggerEnter2D(Collider2D enter){
if(enter.gameobject.tag == "Player"){
isIn = true;
}
}
void OnTriggerExti2D(Collider2D exit){
if(exit.gameobject.tag == "Player"){
isIn = false;
}
}
Hope it helps