I am using Unreal Engine 4’s visual blueprint scripting language to make a shotgun in my game. When I call the function fire, it simply spawns an actor at a given location (this actor moves like a bullet, and has a collision mesh). The only problem is when I want to add another “spawn actor from class” node to the event graph, both of the nodes stop working, and nothing happens. I tested to see if my for loop, select node combination was messing up, but it worked and printed out everything fine, but for some reason when the “spawn actor from class” node is put in more than once, it stops functioning.
Here are pictures provided, if you needed them, and feel free to ask any additional questions.
Have the bullet actors collisions been adjusted? My guess is that they are colliding with each other. If so:
The first index is spawned because nothing is blocking it.
The second tries to spawn but fails because the first one is blocking it, and the others will also fail for this reason.
You can set the collision override on the spawnactor node to “always spawn”. That way you can verify that the logic works and that they will spawn, but they will probably mess each other up. What you want to do is to change their collision presets so that they ignore each other.
Are the bullets set to be destroyed when they collide with something? If so, they could be destroying each other.
To make sure that the bullets are actually spawned, move an arrow a good distance away from where the others spawn.
Can I give you an advice about your design? There is a principle in programming called DRY (don’t repeat yourself). As such, and since you are spawning the same type of projectiles, you can easily simplify your BP with this simple alternative: