Trouble spawning actor at certain distance from another actor.
youdvdk
Member, PRO Posts: 21
Hey. Thanks to all those who take the time to help. I have the player and zombie actors right now and player is always moving so I constrained player's x and y positions to game.playerX and game.playerY. From there I can't figure out what to do. I have tried a few things with magnitude and I must just be doing it wrong All I would like is to create a padding around player so that the zombie doesn't spawn directly on or really close to the player, but at about 100 pixels left or right of the player and also staying in the boundaries of the scene which is 0-320.
Comments
Old thread but may be what your looking for.
http://forums.gamesalad.com/discussion/60525/spawn-in-circle
@BBEnk Thanks. I'll check it out soon and see from there.
I checked it out and that not really what I'm looking for. Instead of inside the radius, I would like it to spawn outside a certain radius and within the scene boundaries. I mitt be able to portray it like this: |------- o ---------| The circle is the player and the zombies can spawn anywhere on the dotted lines.
Change attribute game.randomChoice to random(1,2)
When attribute game.randomChoice is 1
spawn actor at x=random(0,game.playerX-100) y=game.playerY
When attribute game.randomChoice is 2
spawn actor at x=random(game.playerX+100,320) y=game.playerY
That won't account for the width of the actor so you may get half of the spawned actor off screen but it's not too hard to adjust for that.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
@tatiang Ahh. That seems to work great. Thanks so much!