How do I populate an scene with objects

0 favourites
From the Asset Store
3D Rendered, High Resolution elements to create an apocalytic scene or war zone
  • Sadly I arrive to same result as previously. Its spawned in both sides. I tried doing a checkup with variables but that didn't work either. It doesn't seem to take into account the overlapping condition.

  • Here you go. I got to experiment a bit and realized I left out the Pick All. Originally when you do For Each, only the active block is picked, so when you check if its colliding with any other blocks around it, it wouldn't because the only instance it sees in that event is the currently active one unless you use Pick All.

    https://www.dropbox.com/s/88osdmr15uv1m ... .capx?dl=0

    Not quite finished, as you can see with the one at the bottom of the U, but hopefully it will get you going in the right direction.

    Edit: Still broken in several situations, I'll try to refine it a bit...

  • Weird but still have the same issue, I even copy and paste by renaming the objects in your file to those of mine and yet gave the same result. I'm still checking what could be causing this

  • It seems like when you have object bounding boxes directly adjacent to each other they count as overlapping, so this solution might not work as I expected to at all. Gonna think of another way. But don't worry, I'm sure it can be done

  • oosyrag, (without families, took your capx) I think this are the rules.

    https://www.dropbox.com/s/8vwxgc9aku4bu ... .capx?dl=0

  • Didn't get a chance to check out 99's solution since I'm not on latest beta, but here is one working to my satisfaction. It uses the spawn helper itself to check for open spaces around the blocks, then moves them to the correct image point.

    https://www.dropbox.com/s/jy04myos0p47s ... .capx?dl=0

    This bypasses the issue where adjacent collision boxes count as overlapping (the helper sprite is smaller than the block sprite), and you don't want to shrink the collision box on your block because you need it for your platforming behavior.

    Pseudocode:

    For each block, check if space above is empty with a helper.

    If it is not empty, destroy helper sprite (and try next block).

    ELSE if it is empty, destroy the helper above

    Then make a new helper to the left of that block and pick all blocks to check collisions.

    If collides, destroy that helper. Else, move it to the corner.

    Repeat with a helper to the right of the block.

    By the way, this should totally work if you manually set instance variables defining left/right corner, so I'm not sure if you're interested in troubleshooting why that wasn't working. The method I'm using right now is meant to save you the hassle of manually setting corners (as variables) in case you have a large level in the future.

  • I tried a method similar to this one, funny thing in your capx file it works. Also 99's Solution works great although I would love to better understand the concept behind it.

    Still, I have the same problem, helper still spawn on every corner. I did a check up of every thing that could be causing this but with no success. Instead of an animation frame, I created a new sprite to be used as corner and still same issues. It doesn't seem to recognize its overlapping another object.

  • Ok, update, seems to be on my side. I created two brand new sprites and there is no problem at all.

  • Concept behind mine is ...

    I used 4 helper objects, to check for overlaps. The reason why i use helper objects is that checking overlaps with the same instances of an object is a bit tricky. Should use families. oosyrag did not use a family, so i was like, wth, i not gooing to do it too.

    Those helper objects (hor1 hor2 ver1 & ver2) have there origins set in a way that they overlap the questioned object and the object on the left, the right, on top and under. When i was dooing this, i found out that i dont need the 'under' for defining a rule, but i left it in there.

    Now, when you place an object over other objects. And when you pick all objects that overlap that placed object, the expression object.PickedCount gives you the amount of objects that are overlapped. Including the questioned object.

    So, in short, when i place the 4 helpers objects (in the for each loop) on the questioned object, i can according to how many objects this helper overlaps, make rules. And for this concept, there are only 2 rules needed, as you can see in the capx.

    oosyrag does kinda the same, he is using the cornerobjects to dedect overlaps. So he's also not checking overlaps between instances of the same object, wich is as i said very tricky.

    I was a bit suprised by his solution, but i did not understand his rules.

    So i had to find them out, stronger then myself. But i am old school. So i need to see what i am dooing. And helper objects i can see. Now, at this moment, i know the rules, i could translate the idea to an array, or translate it to a loop in a tilemap, if i wanted to. But in the end, what i have given to you is for me the first step in solving things .. see what i do. I often use the tick-top-down-loop first, before making the real loop. Because that way i see, tick by tick, what i do. How it works, or actualy dont work at all. If it works, i bring it in the real loop.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ah ok now I understand, thanks. For the other solution, object count was going insane, so I fixed it by adding on Start of Layout. I might go deeper into your solution after so I can have a better control ( and understanding) of it. I'm still trying to figure out why it worked with new sprites rather than old ones. had to adapt my events to it.

    *Actually is because I set in the sprite properties Collision to Disabled, then it spawns helpers on every one of them since it no longer detects overlapping. I was using a small sprite of 4x4 pixels that I scale up to use as collision since it reduces collisions.

    I'm going to try and adapt the same to this mask instead, or is there any better way to do this?

  • Each way is fine. By now you have seen that for each problem there are 50 solutions in C2.

    Like using that simple 'On start of Layout'. I used to use that heavely. Now i rather use 'once while triggered'. In most circumstances, they do the same. But for me, the last one reads nicer, it wraps my head arround it in a better way.

    That is usaly the factor that makes you choose for one or the other way the most. How it wraps your head arround it.

    There is only 1 thing that you should avoid, (well a few more, but ... ) do not use collission/overlap conditions in big (nested) loops for many objects EACH TICK. That will bring the performans down.

  • Ah ok now I understand, thanks. For the other solution, object count was going insane, so I fixed it by adding on Start of Layout. I might go deeper into your solution after so I can have a better control ( and understanding) of it. I'm still trying to figure out why it worked with new sprites rather than old ones. had to adapt my events to it.

    *Actually is because I set in the sprite properties Collision to Disabled, then it spawns helpers on every one of them since it no longer detects overlapping. I was using a small sprite of 4x4 pixels that I scale up to use as collision since it reduces collisions.

    I'm going to try and adapt the same to this mask instead, or is there any better way to do this?

    Right sorry about that, normally I would put something like this in a function to call on start of layout, or to update during runtime by trigger in case your blocks can move and you need to reposition the corner helpers.

  • Hey np guys, you helped me a lot!

    Now I got to understand things a bit more.

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