how to spawn enemy bullets when actor comes closer [FB]

mitdrissiamitdrissia Member Posts: 11
edited March 2014 in Working with GS (Mac)

Hi guys,
i have a question regarding spawning bullets of an enemy. I have random(0 to 2) turrets spawning every 1.5 sec on spawned pipes.Now is my question, how can i fire the turrets with bullets when the actor comes closer?I used a timer and spawned the bullets (in actor)but the bullets stay on the scene.Also the pipe moves up and down and because of this the way bullets get fired looks strange too.How to solve this.
thank you

Comments

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

    Flappy Tower Defense?!

    Any time that you need to check if an actor is close/closer, you'd be using the magnitude() function. You can Google it and if you have specific questions about it, just ask.

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

  • mitdrissiamitdrissia Member Posts: 11
    edited March 2014

    Ok i tried the magniture part. The part where i need to add a rule to spwan the bullets when the actor comes nearer doesnt work..The turret does not shoot when actor is close to it.It doesnt shoot at all.
    I used the following:if self.distancefrom <50, spawn actor missile turret in front of actor in direction 180 relative to actor, from posititon 0.0 relative to actor.

    Another easier way would be to spawn the bullets every 0.5 sec and then the turret shoots when its on the scene.The problem is that the turret changes from the y position because of the pipe going up and down.
    I need it to shoot to the left.But with this problem the bullets looks strange and stay on the scene. see screenshot below.

    How can i fix this?
    thank you

    image

  • mitdrissiamitdrissia Member Posts: 11

    anybody?

  • mitdrissiamitdrissia Member Posts: 11

    I got it working...It took some time but now it works as supposed to.I used the magnitude attribute like you said to do.Thanks bro

Sign In or Register to comment.