making "one-way" platform

Hello.I’m expanding the unity’s "2D Gameplay Tutorial " to inprove my coding skill.
I want to make the platform like this…

  1. It won’t work as a platform if the player(character controller)'s y position are increasing.
  2. It will work as a platform if the player’s y position are decreasing.

This is my code attached in the platform.But it just works as a normal platform .
Please improve this code.Thanks in advance.


function OnCollisionStay(col:Collision){
   if(col.relativeVelocity.y>0)
     enabled=false;

}

Have you tried the Plane GameObject; it might work!