Newly Spawned Actor Won't Register Held Keys

Hopefully someone can help me to resolve a pretty straightforward issue; I’m currently prototyping a vertical shooter where, for the most part, the player will be holding down the spacebar to fire projectiles from their ship. Every so often, a power-up will appear that, once collected, will spawn two satellite turrets that orbit the player and fire at the same time as the main ship.

However, if the player is already holding down the spacebar when the power-up is collected, it is necessary to release the key and press is again for the event to register and the newly spawned turrets to also fire. I understand that this is caused because the keystroke event has occurred before the new firing actors were spawned, but is there a solution to this? Please let me know if you need any more information.

Comments

  • 3DMA3DMA Member, PRO Posts: 162

    you could use a game Attribute that trigger the actual fire event.
    in Actor: If space bar is pressed, change attribute game.fire to 1
    if space bar is released change attribute game.fire to 0

    in your ships and torrets that should fire set the rule to "if game.fire = 1" -> FIRE
    "if game.fire = 0" don´t FIRE

    This should now work also without releasing the Spacebar when the torrets spawn.

    I hope this helps.

  • InfiniteRocketsInfiniteRockets Member Posts: 2

    That worked perfectly and the game attribute will also let me implement something else that I had in mind too. Thanks a lot!

Sign In or Register to comment.