Actors spawning when other actors approach

Hello I have been dabbling with GS for a few months now working on a project in which I have a very solid design for. One issue I am running into is that I have a spawner that will spawn an actor every so many seconds. The goal of these actors is to attack an actor that I have sitting against the fall left side of the screen. (Side Scroller) I cannot for the life of me figure out how to get the actor to spawn the "bullet" its supposed to fire in which to protect itself.

I want the "bullet" to spawn whenever the invading actors get close enough. I have a semi working tracking system but I cannot get it to operate on its own without me either pressing a button or clicking my mouse. Any help would be greatly appreciated.

Comments

  • SocksSocks London, UK.Member Posts: 12,822
    edited March 2015

    When magnitude (hero.x - attacker.x, hero.y - attacker.y) < distance . . . then spawn bullets.

    Another approach is the simply make a large (invisible) 'detector' actor that surrounds the hero, and have a rule that says when attacker overlaps with this detector then spawn bullets.

  • Saltydog86Saltydog86 Member Posts: 5

    Well I am curious about how both of those would be implemented. I never thought making an invisible character and tying them together would work let alone where to start.

    For the equation where exactly in the Spawner would I apply the equation?

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    If you Google constrain actors gamesalad you'll find a bunch of posts and videos that explain how to do that.

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

  • Saltydog86Saltydog86 Member Posts: 5

    Thank you

Sign In or Register to comment.