On start of layout / loops, logic, collsions?

0 favourites
  • 4 posts
From the Asset Store
100 items casual and logic games. All icons are of a high quality.
  • Hi all,

    having a question concerning "on start of layout"....

    At the start of a new Level, I'd like to put some objects at random locations on the layout, like crates or other obstacles (for some kind of top down shooter game).

    • objects should be picked from a range of suitable objects.
    • objects should have a random rotation, probably slightly variations of size.
    • objects should have a certain distance to each other, to make sure that they can't form unreachable areas. (Probably using collision detection to check?)
    • if this would be visible for the user (maybe it takes some time, like half a second or so), it would be good to hide the process somehow.

    So far, I'm able to set one kind of objects at random locations, with "on start of layout" and a for loop, and give them a random rotation. However, the objects overlap, and when I try to check for collisions to destroy the overlapping ones, they all vanish. It only works if I pick one of these objects randomly (not on start of layout, but every frame) and check for collisions, but that's not a good way to do things, I guess...

    can somebody please give me a hint how to do this at layout start?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Not sure which licence you have, but families can generate different objects very easily. Otherwise you'll have to replicate the functionality by randomly choosing an object inside the loop.

    For the collision stuff, it goes something like this: object is overlapping object, pick instance 1 -> object.destroy, optionally recreate the object when you're done. This will flicker the objects slightly so you might want to hide the process from the player.

    capx

  • Hi Geometrix,

    Thanks a lot! I'm fairly new and right now, toying around with the free edition.

    What I do not understand is, why do You re-create the objects in Your example?

  • Are you referring to the objects I have parked off to the side of the layout? That's a thing with Construct, you need to have at least one instance of all objects at least somewhere in your project before you're allowed to spawn new instances of them.

    It's sufficient to place those dummy instances off to the side of the layout (where the player won't see them), or you can create an entirely new layout (I like to call mine "Parking lot") for them. You'll find that as your project grows, you'll probably have quite a few of these objects set off to the side.

    EDIT: Oh, wait, unless you're referring to the actions in event 3, in which case I'm re-creating objects that were previously destroyed, just so that I've always got 10 instances of the object.

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