[SOLVED] generate 2 objects randomly but not overlap them

0 favourites
  • 2 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • Hi

    I am again here with one new question

    I have a track which has left & right

    (x = 100)= this is (L)

    (x = 200)=this is (R)

    (L) Left is 100 px

    (R) Right is 200 px

    Now I have 2 objects

    Circle & Square

    I am creating both randomly on track L & R

    on every random (1,3) second > create "Square" on Choose(L,R)

    on every random (1,1) second > create "Circle" on Choose(L,R)

    these are overlapping sometime

    I want that

    do not create both at a same time (their should a way for player to go ahead)

    do not create both at same position

    How can i achieve this result

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Make the creation happen in a function.

    For example

    On function "CreateSquare" => Do your creation code.

    Add an event Square - On created

    And add a condition : Square is overlapping Circle

    => Destroy Square

    => Function "CreateSquare" (so that it creates another instance)

    Do the same for your Circle and this should make sure that instances are not overlapping.

    To create them at different time, I'm afraid you may need to change your "every random" event to something more determined, and have the timings calling the creation of instances depend on the other.

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