Top-Down Aiming for AI?

D.D.Q.

New member
Hi!

I have: UCC Third Person, Behaviour Designer and the all the Movement Packages

I am working on the combat implementation of a top-down setting. For the player, I altered the code to not aim at the mouse position, but to be able to target enemies by pressing a button. For this movement state, I just assigned the aim targets' world position instead of the 3D mouse position as aim target in the TopDown.cs script. This way the character will always dynamically face the enemy while being animated properly. This works perfectly.

Now, what I want to do is to apply the same behavior to the enemy AI. I created a top-down AI agent enemy with the character manager and assigned a behavior designer tree that lets the enemy "seek" a transform that I move around dynamically. If the enemy spots the player, I place the transform onto a predefined cover spot nearby, so that the enemy seeks cover instead of just running up the player and shoot. Still, what I would like to achieve is that the enemy, just as the player, is able to dynamically face its current target and shoot while moving into cover. You can easily think of many more instances where this is a desirable movement behavior. Therefore I really hope, that this is possible somehow out-of-the-box?
 
There are a couple of built-in tasks in Behaviour Designer that might do what you need, namely "Look At" (under Actions/Unity/Transform) and "Set Look At Position/Weight" (Actions/Unity/Animator).

(Moving this thread to the BD forum as it's probably more relevant there)
 
Hey, thanks for the reply.

Unfortunately setting up "Look at" just makes the transform rotate towards the target. The legs will not be animated automatically. Furthermore - in the use case I was describing - the character model jitters between looking forward and looking at the target.

"Set Look at Position Weight" has no effect at all. I think this is because the UCC has control over all the bone movement.

To make my issue more clear. In the TopDown.cs script, there is the "public override Vector3 LookDirection". This Vector3 returns the direction the player should face while standing still OR while moving. You assign this script to the "Ultimate Character Locomotion" component on your player.

Now, if you assign the same script to the "Ultimate Character Locomotion" component of a NavMesh AI UCC character, this variable has no effect anymore.

My understanding was that somewhere in the many UCC scripts, there must be a condition saying "If not player controller, ignore lookDirection from top-down controller and always face forward direction". My search for the term "lookDirection" was not successful though.
 
For AI I wouldn't use the Top Down MovementType as that is more setup for a player controlled character. You should use the Adventure Movement Type.
 
Top