Hello, I'm currently working on creating X-Wing Fighter mechanics (like in Rogue Squadron) in UE4. I have four sockets for each gun, but when firing, all four are obviously spawning the projectile. How can I spawn the projectile at the first socket, then the second, then third, fourth and then the first again?
Also right now it only shoots once when I press the left mouse button, how can I create continous input? Do I have to use the axis mapping for that?
Thanks in advance!
Replies
You're using a "Pressed" type of event rather than a "Down" type of event.
Inputs typically have 3 events. Pressed, Down, and Released. Pressed and Released fire only once, when the button is pressed or released respectively. Down continues to return true so long as the button is held.
Second issue: firing sequentially.
You're using a for each loop, so what the code is doing it getting all sockets in the array each time the action event fires, and doing the spawn event for each.
Ref: https://answers.unrealengine.com/questions/129319/foreach-doesnt-stop-executing-on-return.html
it appears the node version of that loop doesn't break between ticks. So what you'll want to do is construct your own iterator and update the index of the socket each run through the loop, switching back to zero when you hit the top index.
So something like the following, but in nodes.
This should get the fire event to run through all the code once each tick until your firing time is back up.