Page 1 of 1

Player Sliding? Pulling my hair out on this one...

PostPosted: Mon Jun 08, 2009 8:20 pm
by jimmynewguy
All right so i have this in the draw actor of the player
Code: Select all
char *key = GetKeyState();
if(state == 0 || state == 1)
{
if(key[KEY_RIGHT]==1&&key[KEY_LEFT]==0&&xvelocity < 3.5)xvelocity += .7;
if(key[KEY_RIGHT]==0&&key[KEY_LEFT]==1&&xvelocity > -3.5)xvelocity -= .7;
}

then on collision with the top of ground
Code: Select all
if(xvelocity < 0)xvelocity += .35;
if(xvelocity > 0)xvelocity -= .35;

when i let go of left the player doesn't stop sliding.
The player does stop sliding on wichever one is on top for the second code, i even tried adding another else and if event to see if it was just a script editor glitch, but it doesn't work! I want the player to slide when he lets go of the keys, but he should stop, right? Is there something wrong with my code? Or is there a better way of doing this?
Thanx, i hate to sound mad but i've been working on this for ever

Re: Player Sliding? Pulling my hair out on this one...

PostPosted: Mon Jun 08, 2009 8:35 pm
by skydereign
This problem is likely caused by your collision settings, not sure though. I can get it to work, but maybe I have a different setup. How are you doing collisions?

Re: Player Sliding? Pulling my hair out on this one...

PostPosted: Mon Jun 08, 2009 9:12 pm
by jimmynewguy
i was doing collisions kinda like raster's where you get the velocity do a physical response then set the velocity like
double mem = xvelocity;
physical response
xvelocity = mem;
it works nice and you don't have to have multiple ground actors like in other collision systems
EDIT: i even tried putting it in the draw actor in case it was the collisions still no luck, i just did if no keys are down instead of collision

Re: Player Sliding? Pulling my hair out on this one...

PostPosted: Mon Jun 08, 2009 9:22 pm
by skydereign
I don't know what to say... It works fine for me... Can you post the .ged?

Re: Player Sliding? Pulling my hair out on this one...

PostPosted: Mon Jun 08, 2009 9:24 pm
by jimmynewguy
-.-
Code: Select all
if(key[KEY_RIGHT]==0&&key[KEY_LEFT]==0)xvelocity *= .7;

that worked
:lol: