Why do I need to reload the layout for it to work properly?

Not favoritedFavorited Favorited 0 favourites
  • 5 posts
From the Asset Store
A sound pack containing 132 laser gun sound effects, including mono and stereo versions of audio files.
  • I am working on randomly generating rooms and have run into something I can't quite figure out... I think it has to do with order of processes or something along those lines that I don't quite understand yet.

    In my project, I have an array that is iterated through and given a random value, it is then truncated to X (2 in example,) options and displays from a tilemap of those options. It then iterates over that to create a border. (Set all values of the edges to Y)

    The issue: When I initially load the layout it doesn't display correctly. Every value in the array is 1 when it should be randomized. Then, when the layout is reloaded it displays correctly.

    https://drive.google.com/file/d/1ZBGSejb2UlaPC7ye3ajV6fr5czr92av8/view?usp=sharing

    An example capx of the issue... But, why is it happening, and how can I get it to load properly the first time?

    Thanks!

    SFT

  • While, I am not completely sure why this is happening, I have found a solution for you. If you convert the event "On start of layout" to an OR block and add "On loader layout complete" it loads on first view correctly.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I don't know what exactly is going on but there IS (probably) some logical issue with how the perimeter is created. Because if you disable the perimeter stuff, it works right away.

    The reason InDWrekts solution works is only because the generation is triggered twice, you can also just call the generate function twice in on start of layout and it works too.

    Here's how I'd fix it

    wackytoaster.at/parachute/roomgen_fix.c3p

  • InDWrekt

    If you convert the event "On start of layout" to an OR block and add "On loader layout complete" it loads on first view correctly.

    Thank you for finding a solution to the problem. It seems it works (almost) no matter what the or condition is. I experimented and you can say on start of layout OR on start of layout and it works as well.

    WackyToaster

    I don't know what exactly is going on but there IS (probably) some logical issue with how the perimeter is created. Because if you disable the perimeter stuff, it works right away.

    Yes, I noticed this as well but was unsure why. Your solution of iterating through the array using x, y variables solved the problem. Thank you for that. Now I am attempting to make this scalable and have run into another issue. I am now iterating this over another array (dungeon_gen) and have got it working mostly-- though when the rooms are generated they are the same.

    The issue: How can I make every room generate with different random values, or why is the room generating with the same random over and over? I assume I need to use the advanced random but am unsure how to implement it... Thank you again for taking your time to help me learn.

    Attached is is a capx of the current issue:

    https://drive.google.com/file/d/1KYb9FGLtULBovXSSX-26XiPzy0ie29TG/view?usp=sharing

  • You don't need advanced random for that. You just made a small mistake and added the offsets when generating the room array so everything generated after the first room was added outside of the arrays bounds.

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