How do I Create object in random place but not a solid oboje

0 favourites
  • 4 posts
From the Asset Store
2D fighting template based in the game that defined the fighting games genre.
  • How do I Create object in random place but not a solid obojets??

    In the past I asked a similar question.

    But now this solution is not good for me because I have a large number of solid objects in different names.

    Is it possible to create a new layer and set that you can not create a new object on layer1 if there is an object at the same location on the second layer??? or something like that.

  • maordany easy try this demo

  • maordany easy try this demo

    I'm afraid I did not understand what you did or I did not explain myself right.

    1. I have a map with a lot of solid objects.

    2. I need to create enemies in a random place on the map (But not on a solid object).

    i use this code on Set Position :

    X = random(ViewportLeft(0)+Box.Width/2, ViewportRight(0)-Box.Width/2)

    Y = random(ViewportTop(0)+Box.Height/2, ViewportBottom(0)-Box.Height/2)

    the "Box" is the solid object and it works well but my problem now is, i have many solid objects with different names and I can not use the previous code because he knows how to work only with object called "Box". and I have to work with an objects called Box01, Box02, Box03 and more.....

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • ..add Box1, Box02, Box03 and more..... in Family"Solid"...

    .add boolean instanceVar for enemy"overlap"

    Enemy Set Position :

    X = random(ViewportLeft(0)..

    Y = random(ViewportTop(0...

    set "overlap" to True..

    Enemy is overlapping "Solid"

    Is " overlap"............................. set position to ..Solid-Solid/2

    Enemy is NOT overplapping "Solid" ..set "overlap" to False..

    maybe.. just maybe... this can work well for you

    (evidently...can not test this..)

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