How do I make one actor spawn another actor only once?

I'm wanting to make a gun that shoots my flying actor into the air based on a power bar then have the camera follow the bird with his controls now in use can anyone help me with this?
I've made things like the canon and other templates but either I end up with more actors than I can shake a stick at or the camera gets stuck on the canon.

Do I need a rule like if canon is pressed then interpolate bird to position Y+50 otherwise (insert full bird rules)? Then maybe move canon to position (x,y) till bird touches ground then destroy actor and move the canon back to restart for a new life etc?

Comments

  • CobraBladeCobraBlade Member Posts: 97
    I may be way off here. But I'd probably have the camera already focused on the bird and have the bird already there, just hidden behind the cannon until the cannon is pressed. Once pressed apply the speed and gravity rules to the bird.
  • WingmanappsWingmanapps Member Posts: 458
    edited June 2013
    @CoolBee

    make an game integer called camera

    BIRD ACTOR
    Create a new rule
    If "birds" self.motion.linear.X is > then 0
    Change attribute game.camera to 1
    otherwise
    Change attribute game.camera to 0

    Create new rule
    If game.camera is = 1
    Control camera

    CANNON ACTOR
    Create new rule
    If game.camera is = 0
    Control camera


    here is a video on how to make a cannon powermeter

  • CoolBeeCoolBee Member Posts: 81
    edited June 2013
    I see sounds like a good idea how would I go about to give it a power meter though?

    You replied quicker than my phone would upload a reply thanks man ill give it a go :)
  • CoolBeeCoolBee Member Posts: 81
    @Wingmanapps That works really good thanks I now have my actor firing into the air based on a power bar, the only problem I have no is how do I limit it spawning my actor? As I only want the one flying actor on screen until it loses a life/touches ground & destroys whereas at the moment I can shoot as many as I want which this also resets the camera to the cannon.
  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772
    You need to set up an attribute to keep track of when there is a projectile on screen. Something like:

    - Make a boolean attribute called shotInPlay and set it false

    - In your shooting rules only allow shooting if shotInPlay is false

    - When you shoot, change shotInPlay to true

    -When your projectile touches the ground & destroys, set shotInPlay back to false

    Then you will only be able to shoot one shot at a time.
  • CoolBeeCoolBee Member Posts: 81
    Hiya @jamie_c thanks that worked, but! It gave me a new problem, I have a scene with basically the start button which switches to the main game scene when it switches it shoots the canon immediately but with no power yet when I try testing the game straight on that scene it doesn't shoot the canon:/ any ideas? I think it registers the "mouse button up" when you press the button thus shoots the canon.
  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772
    Make sure shotInPlay is false when you first go to that scene. Also you might try adding a timer delay before it changes scenes to give the button time to register as up before the cannon ever comes on screen. Just a couple thoughts to try.
Sign In or Register to comment.