Projectile collision filtering

Hi

In my game (semi tactics) I have several Pawns (divided into teams) - how to make that rocket launched by member of one team (AActor derived class controlled by ProjectileMovementController) will NOT generate OnComponentHit events when flying through members of that same team (or fly through them without stopping) ? Team is entirelly my concept, so I propably need to set some collisions flag on the rocket and team members Pawns, so they ignore themselves. But in the settings tab (Collision -> Collision presets) I see only that I can entirelly ignore Pawns, and that is not what I want - I want to ignore them selectivelly, based on their team (I have up to 4 of them))
Is there any way to approach this ? (may be c++ or blueprint, does not matter realy).

Why not just check the team of the object it hit, and if it’s equal to that of the Projectiles’ team (or the projectile Instigators team) - then ignore it and don’t go any further? That’s arguably the best way, it’s what I’ve done for my Hovertank game, which has up to 255 teams (uint8).

that’s what I was doing … BUT I need the rockets to fly through bodies/capsules of team members (no friendly fire).
My another approach was to set only WorldStatic as blocking, and the rest of masks as overlap, then inside beginOverlap make decision if I want to explode the rocket or pass it through the body - but meybe there is something better ?

There is a function called


IgnoreActorWhenMoving

which you can use to disable collision between your projectile and team members.

You would need to loop over all team members and call this function like that:



for(auto CurrentTeamMember : GetTeamMembers())
{
MyProjectile->IgnoreActorWhenMoving(CurrentTeamMember, true);
}


Hope that helps :slight_smile:

Already some good solutions here but I’ll throw another out.

Why not make 2 new collision profiles, 1 for each team (team 1, team 2). Then on rocket launch, setup the rocket collision profile based on the team you’re on:

  1. Block team 1, ignore team 2
  2. Block team 2, ignore team 1

Then on each team member you must set their collision profile to block the opposite team profile and ignore the same team profile. Remember that to block, both object profiles must be set to block each other.

I use this solution a lot.