M
molcap
Guest
Hi everybody!
I'm trying to do a skid system for my game, but it works fine until you press left and right at the same time and I don't know why, when I do that the sprite changes to idle with 0 of image speed and if I press left and change to right too fast he doesn't skid. Also I want to implement a system to run using double tap.
Here's the code:
Thanks
I'm trying to do a skid system for my game, but it works fine until you press left and right at the same time and I don't know why, when I do that the sprite changes to idle with 0 of image speed and if I press left and change to right too fast he doesn't skid. Also I want to implement a system to run using double tap.
Here's the code:
Code:
if (Key_Left)
{
if sign(hsp) <= 0 and not !(Key_Right)
{
hsp = -2.2*run_speed;
if (grounded)
{
flip = -1;
sprite_index = run
}
}
else
{
if hsp > traction
{
hsp -= traction;
sprite_index = skid
}
else
hsp = 0
}
}
if (Key_Right)
{
if sign(hsp) >= 0 and !(Key_Left)
{
hsp = 2.2*run_speed;
if (grounded)
{
flip = 1;
sprite_index = run
}
}
else
{
if hsp < traction
{
hsp += traction;
sprite_index = skid
}
else
hsp = 0
}
}
//Neutral input = 0 movement
if ((Key_Right && Key_Left) or (!Key_Right && !Key_Left))
{
if hsp > traction and sign(hsp) = 1
{
hsp -= traction;
sprite_index = skid
}
else if hsp < traction and sign(hsp) = -1
{
hsp += traction;
sprite_index = skid
}
else
{
hsp = 0
}
if fallspecial = false and hsp = 0
{
sprite_index = idle
}
}