Only one sprite is being recognized

  • Hi there, I'm new to this and the documentation has zero examples.

    I'm trying to make it so that when an object is created, it shoots bullets.

    As of now, only the initial sprite is shooting, the one that was created does literally nothing.

    How do I make it so that the created ones shoot?

    Current event sheet looks like this:

  • + what at the end

  • add a condition of:

    For Each:Small Destroyer

    -> Round logic

    ---> shoot logic

    That will do what you want as I understand it.

  • Your timer event isn't nested under your 'on created' event.

    So when your layout loads, it's running two events when you're trying to run one. It's saying "when a small destroyer is created... " but then doing nothing, because it has no sub events. It's also doing all that code you've asked it to do "every 0.2 seconds..." because it's all a nested sub-event below that timer event.

    You need to have the timer event be a sub-event of the on created event. This way the timer launches because the small destroyer was created.

  • add a condition of:

    For Each:Small Destroyer

    -> Round logic

    ---> shoot logic

    That will do what you want as I understand it.

    That kinda works, I want it to have a randomized delay of when to shoot too.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • > add a condition of:

    >

    > For Each:Small Destroyer

    > -> Round logic

    > ---> shoot logic

    >

    > That will do what you want as I understand it.

    >

    That kinda works, I want it to have a randomized delay of when to shoot too.

    There is a rex timer behaviour that would do the trick.

  • Your timer event isn't nested under your 'on created' event.

    So when your layout loads, it's running two events when you're trying to run one. It's saying "when a small destroyer is created... " but then doing nothing, because it has no sub events. It's also doing all that code you've asked it to do "every 0.2 seconds..." because it's all a nested sub-event below that timer event.

    You need to have the timer event be a sub-event of the on created event. This way the timer launches because the small destroyer was created.

    If I change the event sheet to this;

    , I hear one shot and then nothing else happens, that's not what's supposed to happen, right?

  • Your code in the first comment was more correct (or less wrong).

    "On created" is a triggered event, it's triggered only once. So you should not nest repeating events like "Every X seconds" under "On created", this will never work.

    The best solution would be to add Timer behavior to your SmallDestroyer.

    Also, instead of "Create" action you can define an image point where you want to shoot bullets from and use "Spawn":

    SmallDestroyer on created -> SmallDestroyer start Timer "Shoot" for random(0.2, 0.4) (Once)
    
    SmallDestroyer on Timer "Shoot" -> SmallDestroyer spawn BlueProjectile from Imagepoint "shootPoint"
                                    -> SmallDestroyer start Timer "Shoot" for random(0.2, 0.4) (Once)
    [/code:1tya4kf8]
    
    That's it. Each Destroyer will be running its own Timer, and the Timer will be restarted for a random time after each shot.
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)