[Tactical] How to split the attack task?


I see the attack tasks consists of two things:

1. Move to target
2. Attack target

I need to perform a sequence when the player is out of range, but having both of these coupled makes it impossible.

I want to split those two into separate tasks, but I get the following problems:
1. Duplication, since I inherit from the same class I get all of the fields in the two tasks, I want the attack task target to be the same as the moveto task
2. The second class shows the attack agent is null and also the target transform is null

Please help
Last edited:


Staff member
Splitting into those two different functions will require refactoring with the base tactical classes so it's not something that is straight forward in order to do. What is the purpose of splitting the task? You can implement your own interface for attacking so you shouldn't need to split it up:

Well for example after the enemy reaches the player I want to have a task that sets the animation to the attack stance, Id also like to check while the enemy is moving if the player is more than 50 meters away in that case play a run animation, otherwise play the walk. I also have a task that sets root motion to true while the enemies are moving and then false when they reach their target.

If I have the attack task combining Move and Attack I cannot run my root motion / animator tasks in between them.