# Is it possible to make a Icy/Slippery floor with code with a fixed velocity?

Hello everyone, I’m making a 2D Platformer for android and I’m trying to make an “Ice Level” where ground tiles have the tag “Ice”. Btw I’m programming in c#.

I wrote my own PlayerController Script wich i could post if it’s necessary.

So if the Player walks on the ground with tag “Ice” the velocity of my player should lower in a fixed amount over a fixed amount of time and slides till he stands still.

I’ve tried it now for days and don’t get the effect I want, honestly I didn’t even got it to work with any result.

Now to my question :

Is it possible to achive such a effect only with code when i have a fixed velocity? If yes could someone please help me with the coding or point me out how to achive such an effect?

My idea was to save the last MoveSpeed and multiply it with a “Slide speed” so the MoveSpeed would lower over time but I’m not sure if my code is wrong cause i got no effect.

Do you have some deceleration, or does it stop immediately? If you do have some deceleration you could just multiply the decelerationspeed with 0.1 or whatever to get that effect. You could even do it with the aceleration as well if you wan’t your character to take a bit longer to start running at ful speed. You could determine if the player is standing on ice with the following script:

``````     int TouchingIce = 0;

void OnCollisionEnter2D (Collision2D object) {
if (object.gameObject.tag == "Ice") {
TouchingIce++;
}
}

void OnCollisionExit2D (Collision2D other) {
if (object.gameObject.tag == "Ice") {
TouchingIce--;
}
}
``````

Now you can just look if TouchingIce is more than zero and then the Player is touching atleast on ice object and you could apply the effect! Good luck!