Hi, I have an enemy actor with a CollisionBox and I want him to do different behaviours depending on whom it overlaps with.For example, I want to have a “route” that checks if its the thirdpersoncharacter actor and then do something, and if it is a different actor class(for instance an npc allied to the player) do something else(while ignoring all other types of actors)
How do I go about it?
thanks in advance.
you just need to have the logic to do a basic check. for example for the check to see if its the third person character you could just cast the other actor to thirdpersoncharacter class. if you wanted to see if the other actor was the player then you could use the equal (==) node, plug the other actor pin from the overlap event into the first input on the equal node and a get player character node into the other input, then use a branch. for checking npcs as you mention you will need to have a way to determine if the npc is allied to the player which can be done with tags, so you could take the other actor and then use the actor has tag node to check is the actor has the tag and therefore is an allied npc. how you implement it will determine the scope, for example casting to character will return true more often then casting to third person character.
thank you, so something like this? I guess this will work, but is there a cleaner way that doesnt resort on so many branches to say what it should do?
yea thats the basic idea. as for a cleaner way its difficult since your trying to target such specific cases. its alot cleaner in code but in blueprint you have to get creative so things dont seem so complex.
Thank you I really appreciate your help!