UCC A* Pathfinding Integration and Movement Speed

Zaddo

Active member
After a bit of playing around, I worked out how to adjust the movement speed using UCC, Behaviour Designer, Movement Pack and A* pathfinding.

The A* speed is set on AIPath MaxSpeed. This is set via the Speed setting on the Seek action.

But I found, that I also need to change the MotorAccelleration on the UCC Locomation script.

I might have this wrong, but I could set the AIPath MaxSpeed higher and this didn't really affect the speed or behaviour. Then change the MotorAccelleration to the speed I wanted.

If I did this in reverse and set the MotorAccelleration to the maximum speed I want to achieve, and then dial up and down the AIPath MaxSpeed, I ran into animation issues.

Could you please let me know if I should be controlling AI Speed using the MotorAccelleration in this situation?

Alternatively, what is the correct procedure?
 
That is correct for non-root motion characters. If you are using root motion then you can adjust the speed within the animation.
 
Thanks Justin. But my apologies, I didn't describe the problem very well.

I am trying to make an NPC sprint under certain conditions. Looking at the Character controller, I noted in the code that it is the speedChange ability that makes the character go faster.

So I tried to start/stop the speedchange ability on the NPC, but it makes no difference. I don't know what I am missing. The speedchange appears to multiply the inputVector. So I am guessing this might only works for controller/keyboard input? Currently this is what I do in a class inheriting from IAstarAIMovement.:

locomotion = gameObject.GetCachedComponent<UltimateCharacterLocomotion>();
speedAbility = locomotion.GetAbility<SpeedChange>();
locomotion.TryStartAbility(speedAbility);

BTW, I tried using the Jump ability just to test I was using triggering abilities correctly. The NPC jumped successfully, so I am pretty sure I am calling the speedchange correctly.


If this will only work for character input, how can I create a similar ability for an NPC? is there a property that I can set on Character Locomotion for NPC's to make them sprint?.

EDIT: Problem Solved :) The Abilties have a sequence!!! I just needed to move the "Speed Change" ability after the "A Star AI Agent Movement" so it had a value to multiply!! So obvious once you know. But if you don't.... well 12 hours of debugging code you are not familiar with ;-) But at least I now have a much better understanding of movement and abilities
 
Last edited:
Top