• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

SOLVED Fast Change direction with thumbstick ....

My game is a platform.... i have a problem.

My problem is when i go to left direction and then i go to right direction immediately .... the player state does: movesx -> idle -> movedx because the axis value goes -1 ...then 0...then 1 ..... i would like that the player state goes from movesx in movedx directly...
how can i do?


codice stati.JPG
 
Technically, the same thing could happen with the keyboard, so I'd assume you'd want the idle state based on the speed instead of the input, no?
 
@BattleRifle BR55 , with key this problem doesn't exist because, if press left arrow when right arrow is pressed , the player state does movedx (right) -> movesx (left) ..... with pad (thumbstick) with axis is in right and i move thumbstick in left direction ... thumbstick has valor 1 in right -> then 0 in centre position -> then -1 in left direction .... the player state does movedx - idle - movesx .
 
Last edited:
I get that, but I was speaking on if the player were to release the left key before quickly pressing the right, as the same thing would happen. This is why I suggested changing to the speed instead of the input.
 
Yeah, so it goes back to what I was saying in the beginning, how you should alter your code to compensate for this based on movement rather than input. There isn't anything about your code to suggest that it's only the thumbstick which is breaking things. If you're holding the left key and release it before pressing right, it'll do the exact same thing as moving the joystick from left to right. I feel like you're just too used to switching directions on a keyboard without lifting the currently held key and therefore don't encounter the issue. You can't replicate this setup using a joystick because the direction can only be either/or; you can't be both left and right and release just one. Unless there's something else at play in how movement works which you haven't shown, that's all I can really say.

Also, you can paste the code directly. There's no need to keep taking screenshots. It also makes it easier for us to edit your code if necessary.
 
Risolto !!! i put 1 counter.
function scr_movedx()
{
counterfrictiondx+=1;

image_xscale=1;

//velocitĂ  da zero al max al passo stabilito
hsp=scr_approach(hsp,hspmax,groundacc);

if (global.keyright)
{
counteridle=counteridlemax;
}

//move sx
if (global.keyleft && !global.keyright)
{
counterfrictiondx=0;
hsp=0;
state="movesx";
image_index=0;
}

if (!global.keyright && !global.keyleft )
{
counteridle-=1;

if (counteridle=0 )
{
if (counterfrictiondx<counterfrictionmax)
{
state="idle";
image_index=0;
}
else
{
state="friction";
}
}
}
}
 
Top