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

How to make a spring in GMS2

Q

Quacksonja

Guest
Hello everyone. This is my first post. I had a lot of problems with this. If you do not know what is a spring its a red thing on what you jump and it bounces u high. Please if anyone has a tutorial for this or a code please send it to me!!!!
 
Q

Quacksonja

Guest
TrunX my spring works now but when my player jumps on it it jumps perfectly but when he runs from the spring he is just always jumping and i am not clicking anything.
 

TrunX

Member
Does he jump when running on it? (I thought that's how the spring in Sonic works)
If you want to change that behaviour add a condition like "if vspeed>0" //if the player is falling down

Or is your problem that he starts to constantly jump after touching it even though you're landing on normal ground? In that case some other code is causing the problem.
 
Q

Quacksonja

Guest
yup thats it. When he is touching the normal ground he just jumps ...
 

hippyman

Member
Dude if you want help without some random nice person trying to guess your problems, you need to share more. Show code so we can definitively tell you the issue instead of playing this guessing game. We're not tech support. We're other forum users just like you.
 
Q

Quacksonja

Guest
okay but just one more thing.... When i add
"if vspeed>0"
what do i type next
"if vspeed>0 .........?"
 

DukeSoft

Member
Thats programming 101. Maybe read up on some GML tutorials? If you're having a hard time understanding how an if statement works you're going to have a bad time in gamedev :p
 

Kyon

Member
Try this in the step event.
Code:
if vspeed<0 //if your vertical speed is lower than 0, so it it's moving up
{ //then
   vspeed+=.5; //slowly add vertical speed so it goes down again
} //end if it reaches 0
 
Q

Quacksonja

Guest
not presing anything but he jumps. Spring is invis but i can fix that.
 
S

Scytaic

Guest
Hi, I'm completely new to GMS2 and coding, I saw that it's better to post in an existing thread than make your own of the same issue so I hope it's ok that I post here! I'm also wanting to make a spring, the vspeed=-10 code worked great in a collision event (Thank you TrunX!) and I also added the other code you mentioned in a step event. But my character is also still continuously jumping even when he's back on the ground. All my codes are completely from Shaun's platform tutorial if that's important to know. :) Thank you so much in advance if anyone is able to help me! :)
 

3dgeminis

Member
If you want to just jump when it falls over, you have to see that the speed is positive, and/or that its position on the y-axis is less than the spring.
If the conditions are fulfilled, you have the player jump.
The simplest thing is to do it in the collision event.
 
Top