Not sure what is wrong.....

  • [SOLVED]

    I have an issue where in starting the scene, I set a player variable, as well as a progress bar to that variable (after the variable is set of course) and when I have an event to test that the variable is at or below zero, it changes layout scenes, but its changing even if the variable is above 0.

    The variable is Player.playerHealth.

    I set it at start of layout to the value of 100.

    I then set the progress bar "progress" to Player.playerHealth afterwards.

    I have a text to show the value of Player.playerHealth, which shows 100. And the progress bar turns full green.

    ok, so far so good.

    Upon taking damage, the progress, player variable, and the text all change accordingly, and all three show the numeric value taken away appropriately.

    great. now here is the issue.

    When I then have an event to say if either Player.playerHealth OR the healthbar is < or = 0, then do a "player dead" situation and go to menu (basically just waits 3 seconds atm until I can put animations in there, then goes to menu).

    It doesnt wait until the event is triggered for health to take action. It just goes to main menu every start of the game after 3 seconds as if the even was blank. And none of this is a sub event of start of layout.

    Any thoughts?

  • "I then set the progress bar "progress" to Player.playerHealth afterwards."

    How long afterwards? Do you mean as an action directly below in the same on start of layout event?

    If you take out the OR for progress and keep just the health condition, does the issue still occur? If not then its because you've set progress bar to playerhealth too late, after the check has taken place. If health changes to 0 on start of layout then thats fine, where you set the progress to player health may matter.

    Also note that when I say later I mean this could be the next tick, so not even visible to the naked eye, Your values may appear to be correct wherever your progress bar event is but when the check has taken place to kick off the 3 second timer, this could've been a split second before.

    Of course this is just speculation as we cannot see your event sheet.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Yeah that's what I'm thinking it is too, a timing issue. Since I cannot see that fast lol, it is tough to speculate. But, what I will try is the suggestion of doing one or the other, and maybe a test time delay somewhere also to see if anything changes.

    I do feel the same about it affecting things during the beginning of the scene as an ordered event. Will post progress if I get any :P.

    Do you think I might be able to figure it out by using no time delay in the event that checks for progress at 0%? I have two actions there, the first a delay, and the second a layout change.

    Wonder how I can go about it that way...

    Thanks for the ideas!

  • Hmm not sure what you mean but on thinking about this further you don't even need the OR check as you are checking for the same thing, health = progress, so just check for player health only. You can add in waits to try and debug it, it is probably easy to resolve.

  • SOLVED: I spent the day optimizing the code a bit to see if I can notice anything indifferent much easier, and in doing so, I fixed the issue just not sure how.

    So, what I believe it may have been is an ordering issue. That would make sense when re-organizing. I did not change anything other than deleting the variable inside the progress, and just use progress though that was after the fact.

    Either way, it works now and again I believe it was ordering and/or timing somehow. So, optimizing lesson learned :)

    Since then, I have added more functions for repetitive codes and now things look better and on to the next issue :P

    Thanks for the help.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)