I am trying to create a projectile system where when the player fires the projectile it ignores him and does not generate any overlap or block events but when it hits the enemy it generates an overlap event and destroys itself. The problem I am facing is, how do I get projectile to ignore the player pawn? I thought I would solve this by creating a new collision object channel called “Player Pawn” and setting the capsule collider’s (in the player character blueprint) collision object type to the newly created “Player Pawn”. This Player Pawn would ignore projectiles. However when I do this, my character blueprint stops spawning correctly (There is no mesh present, the camera is locked looking donw negative y axis at (0,0,0).). The object responses are setup exactly the same way as it would be for “Pawn”. Where am I going wrong here? Is this even the right way to approach the problem? Is this broken/a bug? I am not sure where to begin.
instead of making the collision system filter your enemies, why not handle that in the projectiles blueprint?
you could make it overlap any characters and test if the character is the right kind of pawn before blowing up.
to test the type of pawn, use a cast:
drag off an object variable onto a blueprint and type “cast to” and find the type of object you want to check against.
I did not want to do that because If I have many enemies in the future I thought I would have to check against all of them. Please do correct me If I am wrong here. I wanted the system to just be setup once and “just work”. I solved the issue by creating separate collision channels for player projectiles and enemy projectiles. The enemy pawns would ignore collision of the enemy projectile and generate overlap events for the player projectile and the same principle applies to the player projectile.
in object oriented programming, any common functionality that you want between different objects can be achieved by inheriting from a common parent class. so you could make a base class for all of your vehicles and characters that contains a variable like “teamID” that is checked when they are hit.
if the projectile’s parent’s teamID is different from the victim’s teamID, victim takes damage. otherwise, check if bFriendlyFire is true, and if it is, victim takes damage, otherwise, victim tells teammate to watch their aim.
another way to have common functionality is by separating that functionality into a separate component. so you could create a DamageDealingComponent object that all of your enemies add as a variable. that component could contain teamID, friendly fire logic, status affect mixing logic, etc… this component paradigm is nice because it makes it easier to make some enemies own multiple health bars just by adding more damageDealingComponents.
I had a similar problem when I created a new collision channel and object channel. The problem is that when you create these new channels they get set on every object in your game, usually to something like Block or Overlap.
You may need to at least go into your character and/or all the other actors in your game and properly set how they should handle the new trace/object channel.
Then restart the editor. This at least fixed my problem, hopefully yours as well.
Thanks Omnicypher! Looks like I am going to go ahead and do that and restructure my projectile blueprints (I have only 2 at the moment and both are the same really). That way makes much more sense haha.
Hey Zeustiak, I tried doing that but it would still break my character blueprint and my camera would spawn at (0,0,0) and point down the X axis. I also made sure it had the same properties collision as a pawn and everything else in the world treated it the same way as it handled a pawn.