AI Object Interaction

Diggidy

Member
Hello,

I am trying to have an AI agent interact with an object when it enters its trigger. I want the AI agent to look at the object and play audio and an animation. At the moment the AI agent will walk to the spot and just stand there. Any ideas on what I am missing here?
 

Attachments

  • ability.jpg
    ability.jpg
    82.3 KB · Views: 28
  • interactable.jpg
    interactable.jpg
    47.7 KB · Views: 23
It looks like the Interact ability is to low in priority.
Put your Interact ability above your Nav Mesh Agent Movement ability. This will hopefully fix your problem.
Also change Stop Type from Automatic to Manual. My AI agent gets stuck if I put it on Automatic.
 
So it appears i can just have a trigger that calls an ability. Then I can have an ability just play the animation I need. But I am still having issues with rotating the character to look at the object.

private void OnTriggerEnter(Collider other)
{
other.gameObject.transform.parent.parent.transform.rotation = Quaternion.Euler(0, 90, 0);

var characterLocomotion = other.gameObject.transform.parent.parent.GetComponent<UltimateCharacterLocomotion>();
var jumpAbility = characterLocomotion.GetAbility<Jump>();
}
 
Are you looking for something like this?
https://streamable.com/acyys (InteractButton from the demo scene)

If the agent runs into the trigger the "Move Towards" ability will start and puts the agent in the right position.
For rotation you probably need to increase the "Motor Rotation Speed" on the UltimateCharacterLocomotion component when the "Move Towards" ability is active. You can do that with the state system.
You also need to disable the "Nav Mesh Agent Movement" ability when the "Move Towards" ability is active. You can use the state system for that aswell.

I can do a more detailed post with some screenshots if you dont get it to work.
 
Yes, that looks better then what I was thinking. I had a similar thing working on the old version of TPS. A player character could walk up to a chair and sit in it. The action would rotate the player before sitting down. I tried the same thing but it wouldn't work in this version. I'll take a look at what you suggested.

Thanks again, i'll let you know what happens.
 
Diggidy:

I'm still trying to get my character to rotate when it encounters a chair. I'm wondering if you have a solution yet with UCC.
 
Hi John, could you let us know what you've tried so far/what your setup is at the moment? (Feel free to start a new thread.) Have you tried using the state system to increase the character's Motor Rotation Speed, as suggested? (E.g. Nolan in the demo scene has a MoveTowards state that sets his Motor Rotation Speed to 300.)
 
Top