0 Favourites

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

  • 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.

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • 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.....

  • ..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)
Similar Topics Posts Views Last Post
Unread hot topic
378 33,253
part12studios's avatar
part12studios
Unread hot topic
99 10,136
karshinkoff's avatar
karshinkoff
Unread hot topic
167 14,489
DMT2005's avatar
DMT2005