1. Hey! Guest! The 35th GMC Jam will take place between November 28th, 12:00 UTC - December 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice
  2. Hello Guest! It's with a heavy heart that we must announce the removal of the Legacy GMC Archive. If you wish to save anything from it, now's the time! Please see this topic for more information.
    Dismiss Notice

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

Discussion in 'Programming' started by Jacceb99, Dec 21, 2018.

  1. Jacceb99

    Jacceb99 Member

    Joined:
    Sep 8, 2017
    Posts:
    21
    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:).
     
  2. Relic

    Relic Member

    Joined:
    Jun 27, 2017
    Posts:
    726
    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).
     
  3. Jacceb99

    Jacceb99 Member

    Joined:
    Sep 8, 2017
    Posts:
    21
    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:)
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice