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

Non-platform specific questions.

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

Postby jimmynewguy » Mon Jun 08, 2009 8:20 pm

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
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score

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

Postby skydereign » Mon Jun 08, 2009 8:35 pm

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?
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

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

Postby jimmynewguy » Mon Jun 08, 2009 9:12 pm

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
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score

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

Postby skydereign » Mon Jun 08, 2009 9:22 pm

I don't know what to say... It works fine for me... Can you post the .ged?
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

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

Postby jimmynewguy » Mon Jun 08, 2009 9:24 pm

-.-
Code: Select all
if(key[KEY_RIGHT]==0&&key[KEY_LEFT]==0)xvelocity *= .7;

that worked
:lol:
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron