Duel behavior

DragonFist

New member
I'm trying to create a behavior where an AI agent will continuously face the player while moving, strafing when needed. The idea is that the player is engaging sword duels with the Enemies. However, I'm having trouble with this. I thought using the Aim ability from UCC (Third Person) would keep the NPC facing his target, but in practice, it doesn't look that way. I've tried putting a parallel Movement Pack Rotate Towards and Seek, but he always faces his where he is going, not the target. I thought perhaps turning off the "Enable Rotation" on the Rich AI (I'm using A*Pathfinding) but that just results in him always facing the direction that he loaded in and the Rotate Towards doesn't work at all.

Anyhow, I don't know what I'm missing here. Has anyone successfully produced this kind of motion for melee characters using Behavior Designer? If so, could you point me in the right direction?

Thanks in advance.
 
What Movement Type are you using? If you use the Combat Movement Type the character should always look in the target direction.
 
I'm using the Combat Movement Type. The behavior that I'm seeing, at least with using the A*Pathingfinding is that the AI character always rotates towards his goal position, whether aiming or using Rotate Towards to face the player target. So, if sent to a position further away, he turns around, etc.

One thing that I noticed was that the Astart movement script is using the interface IAstarAI. Which makes sense because BD has no idea what implementation the game is using. But as a result the updateRotation flag isn't accessible and isn't in use. I've started writing my own action, with the follow task being used as the base. Probably need to do that anyway since I want to have attacks occur while the agent continues to move, etc. with strafing, etc.

But, anyhow, I think because the pathfinding agent can't be told to not update rotation while following a path, they other tasks can't override the rotation.

I could be wrong. It's just my best guess so far.
 
In the IAstarAIMovement.cs I changed the UpdateRotaton method to this and I now seem to get the behavior that I desired:

Code:
        protected override void UpdateRotation(bool update)
        {
            // Intentionally left blank

            try
            {
                ((RichAI)agent).updateRotation = update;
            }
            catch { }
        }

Probably would need to try the other AI implementations that support updateRotation.

I'm still writing a task to handle the attack and movement stuff as I want to have a rather complex behavior where the AI hangs out at a distance and strafes around the player waiting for an "opportunity" to attack (actually a check on the player to determine whether it is okay to attack based on number attack allowed at a time from multiple attackers and ticks to keep them from continuously attacking).
 
Last edited:
Glad you got it working. Does the IAStarAI interface have a defintion for update rotation? If it does then I would use that (and I'll make the change on my end as well).
 
No, it doesn't. That's why I cast it to the RichAI which does. I think some of the others don't have it, so, it's not on the interface.
 
Just a a quick recording of what I've got so far. Pay no attention to the switching of stances on aiming. I'm not done with the animator, etc.
 

Attachments

  • gamemovie.zip
    985.1 KB · Views: 7
Top