Random location but certain distance from object

0 favourites
  • 4 posts
From the Asset Store
Easily generate many levels from a set of pre-built scenes (Construct 3 template)
  • hi

    ive been trying to figure out how to create an object in a random location on the screen but a certain distance away from a central object.

    this is what i have for random location. every 3 seconds i create an object at location: x = random(0,800) y = random(0,600)

    that works great but i dont want them to appear within a certain area of the screen. this image may help to understand what i mean

    <img src="http://i43.tinypic.com/1zamvp.png" border="0" />

    the red square is my central object

    the blue area represents the no-go zone (distance from object)

    the green circles represent the random objects

    i need the green circles to appear randomly anywhere on screen but not within a certain distance from the central object ie not inside the blue circle.

    is there a formula for this?


  • Try creating the object in the middle of the circle, then using the 'Move at angle' action to move it a distance at random(360) degrees.

  • Or, make a invisible object, pin it to the player, and check the conditionals:

    Created object is not overlapping the invisible object > spawn;

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ashley's idea is the way to go.

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