Turning off friendly fire

I always write descriptive debug lines because In want as much info as possible. Turns out, it is possible to target yourself as the camera is positioned behind the character if you point it just right.

Anyway, this part will go into the gun because that’s the first and easiest way to deal with it, but you could implement this in the character Take Damage override later on in the course if you want to implement this in a more complex manner later.

Anyway, since we don’t have any allies this is pretty easy to implement.

Adjusting line that verifies if you hit a target will solve this issue.

if (IsValid(Target) && Target != GetOwner())

I like using IsValid() because it reads better for me, so you really only need the second part.

Have fun!

1 Like

Thank you for this! :pray:

1 Like

Privacy & Terms