Need help with spawn zone system on isometric field

Not favoritedFavorited Favorited 0 favourites
  • 4 posts
From the Asset Store
3D Rendered, High Resolution elements to create an apocalytic scene or war zone
  • Hello!

    I'm trying to come up with a random spawn system where it spawns enemies in the middle of the red zone, but spawns heavily in the middle, but spreads sort of lightly just like the image.

    I'd greatly appreciate your help!

  • Well maybe something like:

    Var a=0
    Var r=0
    
    Create sprite at 320,240
    Set a to random(360)
    Set r to (random(1)^3)*100
    Sprite: set x to self.x+r*(cos(a)/4-sin(a))
    Sprite: set y to self.y+r*(cos(a)/4+sin(a))/2

    The logic is we create a random point in a circle. Which would be a random angle from 0-360 and a random radius from 0-100. Ah just noticed you wanted an oval so I added the /4 in there to indicate the x radius is 1/4 the y radius. Then you convert that to isometric. In general it’s simpler to just do the math in top view then covert it after.

    Anyways, the main addition is we can modify the distribution of the random points to favor the center instead of more uniformly by doing: (random(1)^3)*100 instead of random(100). You can change the 3 to make the center be favored more or less. Just an idea. There are probably other ways to have random points favor a point but nothing super simple comes to mind.

    Another idea to have them clump toward the center while not overlapping could be to move them to the center and push away from each other if they overlap. But that may be more involved.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Another idea to have them clump toward the center while not overlapping could be to move them to the center and push away from each other if they overlap. But that may be more involved.

    Thank you so much! It works like a charm. I apologize, but I actually forgot to ask how to handle overlapping sprites after they spawn. What would be a good way to resolve this?

  • I mean either you’d need to move overlapping objects apart or you’d repeatedly try a new random location if an object overlaps anything else.

    Another idea would be to manually design some spacing of objects to use, and utilize some alternate arrangements for variety.

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