playMaker

Author Topic: [SOLVED] Select random pre-placed location to Create Object to  (Read 1347 times)

daniellogin

  • Full Member
  • ***
  • Posts: 215
I want to create a random spawning system for my VR shooter. The idea is that when one enemy is killed, it will spawn a replacement that will keep the game going. To keep it from being the same thing over and over that can be memorized, I want the enemy to spawn at a random location.

The catch is that it can't be a completely random location, or the enemy will end up stuck in an obstacle or spawned in a location outside of the range the AI can detect and hone in on the player.

So what I want to do is place down invisible markers in set locations that the enemy can potentially spawn, then when the event happens have the actual location used to be randomised.

Anyone have any idea how to do this?
« Last Edit: March 06, 2018, 10:12:20 AM by daniellogin »

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Re: Select random pre-placed location to Create Object to
« Reply #1 on: March 06, 2018, 09:48:47 AM »
Just place the markers where you want, get their location (vector3), put them into array, and when the enemy needs to spawn, get random item from array as the spawn location.
Available for Playmaker work

daniellogin

  • Full Member
  • ***
  • Posts: 215
Re: Select random pre-placed location to Create Object to
« Reply #2 on: March 06, 2018, 10:12:01 AM »
Wow actually, I can't believe it. Selecting a random object is a built in feature. It's called.... 'Select Random Game Object'.

With that you simply specify a total, nominate each potential object and it's 'weight' (so some can be rarer than others), and set an output gameobject variable.

So easy. Play Maker is awesome.