Many lines of code = issues with code firing in order?

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
  • I can't post a MFA because this is a personal project, but I can describe this situation.

    I am working on a platformer and am in the process of adding pushable boxes.

    I have 2 identical characters that can both push boxes. Their physics and code are identical. The first one has NO issues when pushing boxes.

    When a box is pushed to the right, the X position of the box and character are raised by 0.5 per frame. All sensors are also positioned on the character to insure that they stay in-sync with the characters movements.

    The first character works flawlessly. The second character, with identical code/physics etc, ends up triggering extra code that should only trigger when his hitbox+floor sensor are overlapping an obstacle. This would imply that the sensor is getting out-of-sync with the character by at least 1 pixel and overlapping the box, but if you step through the game 1 frame at a time, this NEVER happens. I've done lots of troubleshooting and the only thing that fixes this is moving the positioning code for the sensor in question closer to the bottom of the events (There are over 700 lines right now. It was around line 235 and now it is at line 698, but still takes place before the box pushing code - lines 700-710.) The first character works the same with his positioning code still at the top.

    I know code is read top to bottom, but can someone explain to me what is going on? Moving this line down fixed the problem, but it throws the organization of my code off a little bit and it bothers me a bit. If I only move the line down a few hundred lines it doesn't fix the problem. There is a certain distance I have to move it before the issue is resolved. Can someone explain why moving the code down could cause the game to function differently?

  • There must be another event somewhere which would effect the outcome of what is happening.

    My guess would be that when the events are in the broken order, you are testing for collisions with obstacles before the box has been moved. In the order that works, I imagine that it is the other way around, and so everything fires correctly?

    For what it is worth, my project has more lines of code than this and I do not have that problem

    SUPER MEGA BEST CAT ADVENTURES Please login to see this link. and Please login to see this link. live now!

  • There is only one line of code that "pushes" the character up. I know my code well enough to pinpoint issues caused by new code without ever really having to do deep troubleshooting because I'm super cautious and anal retentive when setting it up :P.

    The thing is, if you disable this ONE line of code everything works perfectly (sans the disabled line of course.) If you place the sensor positioning code one line above it, it doesn't fix it. if you place the sensor positioning code one line below it, it doesn't fix it. There is still a threshold/distance the code has to be moved before things start to function properly. This would imply that the order of events has nothing to do with it, if you go by the supposed logic that events are always read top-to-bottom and an event on line 8000 can never take place before the events on line 200. Not to mention the code for the character in questions is identical to the other character and is similarly positioned in the event editor- and the other character works flawlessly.

  • Hm.. The events are read from top to bottom, beside immidiate events (Green ones) which are read first, and OnLoop events which are read immidiately after their loop is ran, though still from top to bottom.
    It is hard to say what's causing the issue without seeing the events.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!