Problem with camera frustum culling and spawning projectiles on server

Hey guys,

Recently I’ve been working on some project that requires bow and arrow action. Long story short my idea was to do this:

  1. The bow is attached to a slot on a skeletal mesh.
  2. Create SERVER function on the bow that handles spawning and launching an arrow.

Part of this fire arrow function require getting the start location from which arrow will be spawned and fired. Here is the code:

//#Bow_Attack
//UFUNCTION(Server,Reliable,WithValidation)
void ARegularBow::FireArrow_Implementation()
{

	//Check if bow has an owner and that weapon is not on cooldown
	if (OwningChar && !bIsOnCooldown)
	{		
		//Vector and rotator for camera trace
		FVector  CameraLoc;
		FRotator CameraRot;
		OwningChar->GetController()->GetPlayerViewPoint(CameraLoc, CameraRot);

		//Vector and rotator for this actor.
		FVector Loc = this->GetActorLocation();
		FRotator Rot = this->GetActorRotation();

		//Check for the world
		UWorld* const World = GetWorld();
		if (World)
		{
			//Spawn parameters for projectile
			FActorSpawnParameters SpawnParams;
			SpawnParams.Owner = OwningChar;
			SpawnParams.Instigator = OwningChar;
			

			//Spawn arrow
			LastArrow = World->SpawnActor<AProjectileBase>(ProjectileToFire, Loc ,Rot ,SpawnParams);
			if (LastArrow)
			{			
				
					// find launch direction
					FVector const LaunchDir = FVector(CameraLoc + CameraRot.Vector()*AimMaxDistance - this->GetActorLocation()).GetSafeNormal();
					//Launch the arrow
					LastArrow->FireInDirection(LaunchDir);		

				
			}
		}
	}
}

Here is where things get messy. When SERVER is not looking with the camera toward the client, camera frustum culling stops all the animations for that (client) object on the server. Having this in mind my variable FVector Loc = this->GetActorLocation(); return the wrong position of the bow and client fire arrow from a weird spot.

The problem mostly occurs when the round is finished and all characters respawn with animation that pulls character from the ground if the server does not look toward the client, client fire arrows from the ground.

Questions:

  • Do you have any suggestions on how to
    overcome this issue?
  • Is there a way to get the location of
    the actor from the client but
    execution to be on the server with
    those values?

or

  • Is there a way to exclude skeletal
    mesh from camera frustum culling or
    manually force animation updates on
    the server?

Thanks!

Are you using a listening server I presume, since you say that the server renders, or am I wrong?

Yes, I am using the listening server as one player. Tried with dedicated too but in this case, Client 1 has the same problem.

the location and direction of character on server is not identical to what it was when client fired.(duo to network delay , …)
so you should send spawn location and direction of the arrow with your server rpc.
although depending on your gameplay and network this might not be the right way of handling projectiles at all.