playMaker

Author Topic: Spawning from a random offset with restrictions  (Read 2141 times)

Resistance21

  • Playmaker Newbie
  • *
  • Posts: 7
Spawning from a random offset with restrictions
« on: October 17, 2013, 01:51:34 AM »
Hey,

I am trying to Spawn enemies around my player which are spawning out of view of the camera, This is a top down shooter game.

The way I am trying to do this is using the player as the spawn object and then using a random (X,Z) off set from the player. I have it working fine generating a random X and Z, the problem comes when I want to put a restriction in the generating of the number to be randomized all around my player.

I need to put a restriction like this:
 -50, -25, 25,50 for X and to not generate any number between -25 to 25.

I have tried looking through the actions list but can’t seems to find something that will work.

Thanks for any help given.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Spawning from a random offset with restrictions
« Reply #1 on: October 17, 2013, 05:27:41 AM »
Hi,

 One way to go is the following:

 create a random between 25 and 50. and then randomize the sign, so you get either a minus or minus range of 25 to 50.

 does that make sense?

bye,

 Jean

Resistance21

  • Playmaker Newbie
  • *
  • Posts: 7
Re: Spawning from a random offset with restrictions
« Reply #2 on: October 17, 2013, 06:28:07 AM »
Yeah that makes sense.

How would I go about randomizing a negative and positive value?

I cant think of an action that would do this.

Thanks.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Spawning from a random offset with restrictions
« Reply #3 on: October 17, 2013, 07:11:07 AM »
Hi,

Use for example "send random event" action and on one state you multiply your result by -1

or use random bool and if true, you multiply by -1

bye,

Jean

Resistance21

  • Playmaker Newbie
  • *
  • Posts: 7
Re: Spawning from a random offset with restrictions
« Reply #4 on: October 17, 2013, 07:39:28 AM »
Okay makes sense, I'll try set something up based on that.

Thanks again.