AIPerception EyesSight

Hi everyone,

I’ve been recently implementing perception to my AI and i did override:
GetActorEyesViewPoint on both AI controller and AICharacter.

The perception system rotate in adequation with my eyes socket until… i run client only.
the perception doesnt rotate anymore using 1 or X client.

If i set listen server with one or no client the perception is updated to the eyes rotation as expected.

So in conclusion as soon as there is no ‘client’ server playing the perception is not being updated at all on all clients, is this a known issue ?
I did not saw any similar issue, been trying to set every possible thing ‘replicated’ but never got any success.

cpp class:
IAnimal:

void AAnimalAI::GetActorEyesViewPoint(FVector& OutLocation, FRotator& OutRotation) const
{
	OutLocation = GetMesh()->GetSocketLocation("HeadSocket");
	OutRotation = GetMesh()->GetSocketRotation("HeadSocket");
}

AIController:

void AAnimalAIController::GetActorEyesViewPoint(FVector& OutLocation, FRotator& OutRotation) const
{
	if (_agent)
		return _agent->GetActorEyesViewPoint(OutLocation, OutRotation);
}

Bump

Hi, in your AI mesh under “Optimization” did you try to set it to “Always Tick Pose and Refresh Bones”?

1 Like

I dont know where this comes from but it definitly working thanks alot :slight_smile: !

The problem was that you’re using a socket location and rotation of your mesh in the GetActorEyesViewPoint, which is driven by animation. But by default the animation does not seem to update those socket transformations, unless the mesh is in view (or unless you set it to “Always Tick Pose and Refresh Bones”, then it will udpate always, regardless whether its in view or not).

Which means that with the default behavior, your code would only work if the mesh is in view of the server. And if you run as client, then you have a server in the background which doesn’t render anything, so it won’t work there (unless you set it to always refresh the bones).

That setting is for optimization (e.g. if the animiations would be cosmetic only, then you would only need to update them when in view of the player).

1 Like

Good explaination thanks alot.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.