Making Homing projectile not targeting the character that shoot it

Hello, I currently have this system to look for actor with Homing tag:

Some actos with the tag Homing are the same class as the player character, for example:
My player character is CH_Human, and some npcs are CH_human as well.

since the closest actor will always be the player character the projectiles always chase the player character that shot them.

How can i avoid this? Thank you in advance

in addition to check the distance, do a “get player character” and then do an == check on that. If it is the player character, leave the True branch empty.

So, in plain language what you’ll say is:

If the Actor is in range AND is not the player character, then…

1 Like

Well, what if my character is driving a tank and the missile comes from the tank? since i posessed the tank, the character is no longer player controlled. Also how do i make it ignore allies?

Use tags to know what to target.

1 Like

In my game I have a class for projectiles, and it has a “expose on spawn” (check in the details panel to toggle that) variable for “who fired me”. This is an enum that has entries like, “player, enemy type 1, enemy type 2” etc.

Then on the projectile hit event I can just check that enum in cases where it matters.

1 Like

Generate a unique string hash for the character. Add that string to “Actor Tags”.

In the projectile class create a string var, Name it “OwningHash”. Set the var to instance Editable & Expose on Spawn. Pass the characters hash to the projectile on spawn.

In your tracking logic check the OwningHash against potential Targets as an exclusion.

Otherwise, get the hash of tartget and define a “TargetHash”…trace logic for tracking should check each update.

1 Like

Thank you all for the help it worked :slight_smile:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.