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?
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.
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.