- Home /
AI agent reach target at a fixed position
Hello all,
I keep on editing this question hopping it will become more answerable.
I have a scene of a supermarket. Once my user approaches a shelf, the AI is approaching the user. My quest here, is to have the AI on a fixed position by the user, as for right now it varies. My idea was to use the x,z position of the user, and have the AI stand on the same x but different z positions. I must say, that I have more than just one AI, and I need them to stand in one line with the user. So perhaps you'd suggest another approach.
here's a piece of C# script:
public void SpecificPoint(Vector3 target, Transform player)
{
alreadyPicked = false;
enRoute = true;
playerTransform = player;
targetLocation = target;
initialPlayerDistanceFromShelf = Vector3.Distance(targetLocation, playerTransform.position);
shopper.navMeshAgent.destination = targetLocation;
shopper.animator.SetBool("Walk", true);
}
I've tried transform.Translate but this would have the AI suddenly appear by the user.
This is tagged VR, as it's a VR simulation.
Have you tried using the Lerp function ins$$anonymous$$d of translate? https://docs.unity3d.com/ScriptReference/Vector3.Lerp.html
You can use it to gradually move an object towards something in a smooth transition.
I've tried it it didn't really work for me. I'm now going to a new approach.