Download

Creating a chained lightning projectile that bounces from enemy to enemy in Blueprints

I am looking for some help with the following:

I’d like to create a bouncing projectile that is fired from the player character and will strike enemies with LoS (Line of SIght). These electrical projectiles will damage the enemy and the bounce to the closest enemy within LoS.

Do you all have any tips on where to start with setting up something like that in Blueprints?

Thanks,
AD

Hi Raidmoot,

Maybe start with creating a list of nearby “enemies”. How that works entirely depends on what data you have on your enemies. Assuming they are a bunch of actors in the scene, you could lean on the physics system to test for an overlap, sort results them based on distance, and perform line traces to verify line of sight.

If you don’t mind some more randomness, it might be interesting to lean entirely on line traces fired off in random directions over the course of multiple frames, until they hit a suitable target.

If any of that is slow, you’ll want to look into ways to reduce the amount of work that needs to be done (e.g.: object channel for affected enemies).

Damage depends on how that works in your game.

Visuals could be done in many ways, and finding the best way for your game is one of the things that places the word “work” in the word “artwork”.

All that said, this seems like fairly basic stuff, and you might want to start by learning more of the fundamentals of gameplay programming in Unreal. A somewhat complex example like this can definitely help to keep you motivated to move forward. But you have to be lucky to get a useful reply in the forums.

1 Like

This is a similar post you might find useful:

1 Like

Excellent ! Thanks for the link to the other work @pezzott1 and thanks you @RC-1290 for the quick rundown.

Question - I am fairly new to blueprints. Would it be best to have a blueprint for my projectile and for the targets? Also, would I store these arrays on the targets vs the projectile?

The projectily only goes to places and the character is the one that creates that list of places.

Okay - so I would need an array that is stored on the Player Character as well as an array that is stored on the enemy pawn ?

No. Enemy pawn knows nothing of this, it just recieves the damage. All logic can be in a component inside the character.

thanks!

Also, would the same logic be sound if the targets were moving?

The array is populated in a single frame. The jump happens after, so you can implement additional checks during each jump if you think is necessary.

@pezzott1 would you mind posting your array structure for storing and checking for the next bot?

Personally I’d pack all the chain logic in the Projectile. Client (character) should only fire the projectile. What it does on hit/overlap should reside in its logic.

Off the cuff (1st cup of coffee)…

On hit : verify target (cast) If character → Multi Sphere trace, set radius around the hit pawn (ignore hit pawn)

Loop results: store distance and transform of pawn (float & hit actor ref). As you loop check if the distance is less than current stored float. If so, line trace for LoS. If hit update the stored values.

– note default float distance should be well beyond range of radius (e.g. 10000000cm)

On loop completion: If you have a nearby target, destroy current projectile, spawn new projectile firing at nearby target.

This should give you a target to target ricochet projectile. Only other thing I’d do is add the already hit pawns to an array for exclusion on ricochet. And I’d limit the ricochet count.

2 Likes

Thanks!