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

Making an object not go by a certain point?[SOLVED]

J

Jacceb99

Guest
This is my code. posY being the point where it shouldn't go past.

Code:
//STEP EVENT
if y > posY
{
y=posY;
}
I thought this would make the object teleport back 1 pixel to posY everytime it goes past it. And it kinda works, but if the vspeed is to high i think, it gets stuck(The object switches to positive Vspeed sometimes and is supposed to go up again). Which in my brain is impossible because if for example it goes past the point by 5 pixels in one step, y is still larger than posY and it should teleport back. Idk maybe the issue is obvious here. Thanks in advance:).
 

Relic

Member
Nothing wrong with the code you provided. It will be some interaction between this and the rest of your movement code. Please give the entirety of your step event related to movement and any other code that can manipulate movement (e.g. collision code).
 
J

Jacceb99

Guest
Nothing wrong with the code you provided. It will be some interaction between this and the rest of your movement code. Please give the entirety of your step event related to movement and any other code that can manipulate movement (e.g. collision code).
Thank you very much, This led me to look closer at some other code and by using "debug_show_message(vspeed) i could see that it stopped getting new vspeeds after awhile, issue being for some reason my alarm stops resetting itself.Will have a look at it later. Cheers:)
 
Top