1. Hey! Guest! The 32nd GMC Jam will take place between Feb 22nd, 12:00 UTC (Friday noon) and Feb 25th, 12:00 UTC (Monday noon). Why not join in! Click here to find out more!
    Dismiss Notice

Fundamental question

Discussion in 'Programming' started by Jar, Feb 10, 2019.

  1. Jar

    Jar Member

    Joined:
    Jan 1, 2019
    Posts:
    4
    Some background first:
    I'm coding a platformer from scratch, and going one step at a time to make sure I optimize my understanding of GMS2. My confusion stems from the following scenario:

    The game is a 2D platformer.
    In the player's Create event, a state machine is enumerated. In the step event, inputs are detected, and the state machine switches between the grounded and airborne states.

    Why is it that in the airborne state, I collide with other objects although I've so far only set the collision to happen in the Grounded state? Shouldn't the engine only be executing the airborne script while that one is active, and not perform any other script than the player Step event?

    I believe this stems from a misunderstanding of some fundamentals of the engine and its protocol for executing code
     
  2. Kepons

    Kepons Lost The Bet

    Joined:
    Jun 20, 2016
    Posts:
    87
    It's impossible to say what causes your problem without seeing your code, but from my personal experience it sounds like some simple mistake/oversight in your code.
     
    Bentley likes this.
  3. Binsk

    Binsk Member

    Joined:
    Jun 22, 2016
    Posts:
    482
    Where and what is your collision code? Are you using the collision event or are you handling collisions yourself? If using the collision event are you using the "solid" option (never use that... ever)?
     
  4. Jar

    Jar Member

    Joined:
    Jan 1, 2019
    Posts:
    4
    No solid stuff. Basic collision code (the forsaken Spalding one). I've set my object player to collide with walls in the GROUNDED script, not the AIRBORNE script. Yet I know with certainty that I am in the airborne state when my player is falling yet I can still collide with walls as if the engine kept the collisions defined in the other script in memory
     
  5. Danei

    Danei Member

    Joined:
    Mar 23, 2018
    Posts:
    177
    How about posting your code? Not everyone has watched that specific video, and even if we have, we're not likely to remember exactly how it does things.
     
  6. chamaeleon

    chamaeleon Member

    Joined:
    Jun 21, 2016
    Posts:
    743
    I assume you have sprinkled your code with lots and lots of show_debug_message() calls to highlight important variable values and which script and event code path are exactly executed under what circumstances?
     
  7. Gamebot

    Gamebot Member

    Joined:
    Jul 3, 2016
    Posts:
    159
    Without YOUR code no one will know.
    Is it possible you have your collision code in the step event by itself always executing.
    Might it be possible your going to and or from a state but not the reverse?
     

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