Hi I have two projectile BPs at the moment (player and enemy) but there will be more as the player acquires new weapons as well as more enemy types.
Now I have a collision issue:
The general youtube tutorial from UE4 does not work for me because the whole “get forward vector * 500” to spawn the projectile far outside the player so it doesn’t collide design looks like garbage plus for design reasons I want the projectile to spawn in the player / enemy.
This led me to using Overlap Events rather than hit so that the player doesn’t get stopped mid air when he shoots.
I also checked “generates overlap event” on all the static meshes in my level.
Now the BP gets really ugly when I try to work out the collision handling.
These are the types that e.g. the player bullet can collide with:
- The character: Always an overlap event on spawn since it spawns in the character → desired result: do nothing
- Another Player Bullet: Depending on character movement this happens sometimes → desired result: do nothing
- Enemy Bullet: Well two people shooting each other that happens sometimes, I just want to play some particle effect while they cross and stop it when they are done crossing and go on their respective ways.
- Enemy: Overlap event: Apply damage, play effect, destroy actor
Now is there some way I can make an enum with all the types of things it can collide with? Because right now I am doing something ugly and something not scalable to mutliple different bullet types:
The player bullet has a OnComponentBeginOverlap Event that I sequentially cast into “myCharacter” and if that cast fails than cast into “player-bullet” and if that fails cast into “enemy-bulley” (success = play effect), if that fails cast into “enemy”. On success apply damage, play effect, destroy, and on fail, by process of elimination it has to be a piece of level geometry and it should just destroy the actor.
As you can see that is bloated and if I add another type of projectile I have to throw another cast in there and of course replicate these cast chains in all other types of bullets with small alterations.
Is there a better way to handle this like with an enum which I can switch on (or any other technique for that matter)???
Thanks guys!