Random Spawn Outside Camera View

salochin59salochin59 Member Posts: 25
edited April 2012 in Working with GS (Mac)
I have a Actor that randomly spawns enemies. Works great over all. The only problem I have is that at times enemies appear right in front of the player. Is their a way to tell the program not to spawn enemies within view?

Best Answer

  • salochin59salochin59 Posts: 25
    Accepted Answer
    Nevermind. Stupid me. I forgot to revert my spawner to prototype. Now it is working. Thank you

Answers

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Spawn actor position x=0 y=random(0,480) on an iPhone landscape will spawn the actor/enemy at the edge of the screen at a random height. You can adjust the 480 as needed for your device.

    If you don't want the enemies to be at the edge of the screen but also not near the player, you can constrain game.playerX and game.playerY to the player's location and then in the spawner actor, have a rule that spawns the enemy at x=random(playerX-300,playerX-200) and y=(playerY). Or you can randomize the y value as well... up to you. The -300 and -200 will spawn an enemy at a range of 200 to 300 pixels to the left of the player.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • salochin59salochin59 Member Posts: 25
    Thank you for the response. I tried what you suggested but nothing seems to be happening.
Sign In or Register to comment.