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!!