Whats up everyone!
I had a question about Npc spawning and i figured this was the best place to ask.
Im sure that this thread will help alot of people now and in the future.
What i have is a link to a game called Terraria,for those of you that dont know much about this game you can look it up on google pretty easy,Its a well known game.
What im trying to figure out is how to create the Spawn Logic that they have in place inside this game,I want to have a smarter way of choosing a spot to spawn my Npcs/Mobs and from what i read,I use Tilemaps so it is similar to how the tiles are used in Terraria,This sounds like it is a winner for any sandbox games and other genres aswell.I will copy and paste it inside this post for anyone that thinks they know how to recreate this triple A logic inside construct 2.
Thanks guys,I hope the info in this thread helps you guys out in some way.
How Do We Recreate This In Construct 2?
When the game decides to spawn a monster, it will first choose a random tile within a rectangle around the player. The maximum distance from the player it can choose from is 84 tiles to the left or right, and 47 tiles up or down. If the picked tile is solid block, it will try another one. If the picked tile has a wall that blocks monsters from spawning, it will also try another tile.
Once an empty tile is found, it moves down until it finds the ground. If there is enough space for a monster to be spawned at this location, this will be the tile it chooses. The exception to this is when the player is in an area where Harpies can be spawned. In this case the game does not attempt to find a ground tile.
The chosen tile is then checked to make sure it is not within the "safe" area around the player. Monsters cannot spawn less than 62 tiles away left or right, or 35 tiles up or down.