Attacking

Rick

New member
Just got the Tactical pack. Looking at the Attack() method for the IAttackAgent I see it only returns the position of the target not the actual target itself. This works fine for the demo since it fires off a bullet, but I'm looking at melee (sword) attacks. I wasn't going to do any sort of collision on the sword but more of just apply the damage to the target game object, but not 100% sure how I can get that target game object from withing the Attack() override method? Any thoughts on that?
 
Last edited:
This will require modification to the Attack method. There isn't an override so for your use case you'll need to change the return type.
 
OK, I was thinking I might need to. You would have the object itself to get the position now anyway so just curious why not just pass the object in the first place and we would be able to get the position (or any component for that matter) from it if we needed?
 
I also added a SharedGameObject to Attack named Target. This way things like WithinDistance and actions like that can get a target and Attack can use that vs always finding the closest. I use this specifically for when I as the player direct a unit to attack some target that might be far away. On attack it sends a message to that enemy passing the unit to it which is stored in a BT variable that Attack then uses to know this is the unit attacking me so now I'll attack them.

Just seemed like a more obvious clean cut way of doing that vs Attack always picking the closest of a given tag. Seems like it can add more flexibility as I want my enemy units to seek out villagers and attack them, but if Militant's attack the enemy they can change to attack the Militant which won't have the same tag as the villagers. It's like the enemy seeks to attack weaker units and avoids military units unless attacked my military units, then they'll fight back.
 
Top