• 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!

GML Unnecesary expresion DoubleJump used as a statement

G

GalGames

Guest
I want to set Double-Jump to my sprite and I get this error. My friend gave me his codes of "Double-Jump". He uses Game Maker Studio 1 and I use Game Maker Studio 2. He said the codes he gave me would serve on Game Maker Studio 2 and I get "Unnecesary expresion DoubleJump used as a statement. Here are the codes:

Code:
//Salto
if (keyJump && bolGround) Vy = -VyMax;

//Doble Salto
if (keyJump && !bolGround and (DobleJump > 0))
{
    Vy = -VyMax;
    DobleJump==;
}
In Create event DobleJump is defined as 1;
 

Simon Gust

Member
I want to set Double-Jump to my sprite and I get this error. My friend gave me his codes of "Double-Jump". He uses Game Maker Studio 1 and I use Game Maker Studio 2. He said the codes he gave me would serve on Game Maker Studio 2 and I get "Unnecesary expresion DoubleJump used as a statement. Here are the codes:

Code:
//Salto
if (keyJump && bolGround) Vy = -VyMax;

//Doble Salto
if (keyJump && !bolGround and (DobleJump > 0))
{
    Vy = -VyMax;
    DobleJump==;
}
In Create event DobleJump is defined as 1;
Try
Code:
//Salto
if (keyJump && bolGround) Vy = -VyMax;

//Doble Salto
if (keyJump && !bolGround and (DobleJump > 0))
{
    Vy = -VyMax;
    DobleJump--;
}
You had == in the code which should have been --, since == gives an error (gm wants a statement for that), -- is the logical solution.
-- is an abbreviation for -= 1, it subtracts 1 from the variable DobleJump.

Also, don't forget to set DobleJump to 1 when you are on the ground so you get your jump back.
 
G

GalGames

Guest
Try
Code:
//Salto
if (keyJump && bolGround) Vy = -VyMax;

//Doble Salto
if (keyJump && !bolGround and (DobleJump > 0))
{
    Vy = -VyMax;
    DobleJump--;
}
You had == in the code which should have been --, since == gives an error (gm wants a statement for that), -- is the logical solution.
-- is an abbreviation for -= 1, it subtracts 1 from the variable DobleJump.

Also, don't forget to set DobleJump to 1 when you are on the ground so you get your jump back.
Thanks you solved it, and I'm a beginner and I'm watching tutorial. Please, can you put the code to set DobleJump to 1 when I'm on the ground to get my jump back? Thanks a lot if you do.
 

Simon Gust

Member
I'm guessing that bolGround is the statement that checks for ground contact.
If that is the case you can do simply
Code:
if (bolGround) DobleJump = 1;
 
G

GalGames

Guest
I'm guessing that bolGround is the statement that checks for ground contact.
If that is the case you can do simply
Code:
if (bolGround) DobleJump = 1;
Thanks for your help but I put this code:
Code:
//Velocidad vertical
if (!bolGround)
{
    Vy = scrApproach(Vy, VyMax, Gravedad);    //Caída libre
}
else
{
    if (DobleJump == 0) DobleJump++;
}

//Salto
if (keyJump && bolGround) Vy = -VyMax;

//Doble Salto
if (keyJump && !bolGround and (DobleJump > 0))
{
    Vy = -VyMax * 0.75;
    DobleJump--;
}
"Velocidad vertical" in english is "Vertical Speed". I modified it as my friend told because he noticed he comitted an error. But, thanks for help. :) :)
 

Simon Gust

Member
Thanks for your help but I put this code:
Code:
//Velocidad vertical
if (!bolGround)
{
    Vy = scrApproach(Vy, VyMax, Gravedad);    //Caída libre
}
else
{
    if (DobleJump == 0) DobleJump++;
}

//Salto
if (keyJump && bolGround) Vy = -VyMax;

//Doble Salto
if (keyJump && !bolGround and (DobleJump > 0))
{
    Vy = -VyMax * 0.75;
    DobleJump--;
}
"Velocidad vertical" in english is "Vertical Speed". I modified it as my friend told because he noticed he comitted an error. But, thanks for help. :) :)
This does what I suggested so you should be fine.
 
Top