I can't get the world "Z" coordinate of a SceneComponent (for the client)

I’ve been trying to find out what’s happening for two days.
I have made the code in C++ and also in blueprint.
Change the projectile for a cylinder.
The same thing always happens.
The Z axis coordinate is not set correctly for the client.
Until the client enters the server’s field of view.
Only then will the Z coordinate be set correctly.

Video: (Cylinders are spawning in the floor untill server see the client then cylinders are spawning in the weapon annon as would to be).

Log:

Blueprint Code:

C++ Code:

void AWeapon::SpawnProjectile_Implementation(APawn* TheInstigator, TSubclassOf<AActor> Projectile)
{

	const FVector SphereLocation = WeaponSphereComponent->GetComponentLocation();
	const FRotator SphereRotation = WeaponSphereComponent->GetComponentRotation();
	const FVector  SphereForwardVector = WeaponSphereComponent->GetForwardVector();

	const FVector SpawnLocation = FVector
	(
		SphereLocation.X + SphereForwardVector.X * 50.0f,
		SphereLocation.Y + SphereForwardVector.Y * 50.0f,
		SphereLocation.Z + SphereForwardVector.Z * 0.0f
	);	
	
	UWorld* World = GetWorld();
	if (!IsValid(World))
	{
		message::Error("AWeapon::SpawnProjectile -> World is NULL");
		return;		
	}	

	FActorSpawnParameters SpawnParameters = FActorSpawnParameters();
	SpawnParameters.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
	SpawnParameters.TransformScaleMethod = ESpawnActorScaleMethod::MultiplyWithRoot;
	SpawnParameters.Owner = this;
	SpawnParameters.Instigator = TheInstigator;
	
	World->SpawnActor(Projectile, &SpawnLocation, &SphereRotation, SpawnParameters);
}

All actors are relplicated like this.

i’m doing somthing wrong? it is a bug?
Please, Any comments that prevent me from falling into madness!!! (i’ll appreciate it so much)
Thank you so much!!

Only thing I can think of - is WeaponSphereComponent returning null for some reason?

Maybe set a check at the beginning and output a UE_LOG if it is coming back null.

1 Like

No, the SphereComponent is valid.
it is in the cannon of the weapon.

Anyway, I will the verification. It’s good practice. Thanks for the observation.

bump the post

I see this message in the log

Warning: ClientAdjustPosition_Implementation could not resolve the new relative movement base actor, ignoring server correction!

Can It be the problem cause?