Page 1 of 1

Walking on ice

PostPosted: Wed Apr 09, 2008 8:38 pm
by jimmynewguy
:evil: I've tried and tried, but i just can't make it seem like my platform character is on ice :oops:
is there any way to do this.... I don't care if its not simple and if you don't understand what i mean well....
- the character accelerates in the direction he's going
- the character slso slides on key up

i can do it, but it seems choppy like he will go from here - to here - in just a second
:lol:

plz help :mrgreen:

Re: Walking on ice

PostPosted: Wed Apr 09, 2008 9:48 pm
by DilloDude
Here's where something like a 'traction' variable comes in hanbdy. It can be adjusted depending on what type of ground you're on, if you want different types of ground. Otherwise, you can generally hardcode it in.
You need to adjust xvelocity, or another variable that simulates xvelocity. Something like this:
Code: Select all
if (moving_right)//some condition when you should be moving right
{
    if (xvelocity < 5)
    {
        xvelocity += traction;
    }
    else
    {
        xvelocity = 5;
    }
}
else if (moving_left)
{
    if (xvelocity > -5)
    {
        xvelocity -= traction;
    }
    else
    {
        xvelocity = -5;
    }
}
else // when not moving, you should slow down
{
    if (xvelocity >= traction)
    {
        xvelocity -= traction;
    }
    else if (xvelocity < -traction)
    {
        xvelocity += traction;
    }
    else
    {
        xvelocity = 0;
    }
}

Re: Walking on ice

PostPosted: Thu Apr 10, 2008 12:52 am
by jimmynewguy
thanx, i also discoverd another way, points ++ anway :D , where collision on ice = physical response of .6 for both actors creating a sliding effect