Update: With John’s help I have now succeeded in resolving this issue entirely, meaning no initial frame of incorrectness due to the bRotationFollowsVelocity and the bouncing of projectile still works correctly
Solution I used is to initially set the RotationFollowVelocity to false, and then set it to true on a timer via the local postinit component
so it runs on both client and server automatically and independently (no chance of server calling this too early)
AVictoryProjectile::AVictoryProjectile(const class FPostConstructInitializeProperties& PCIP) : Super(PCIP)
{
MovementComp->bRotationFollowsVelocity = false;
}
void AVictoryProjectile::CorrectRotationFollowVelocity()
{
MovementComp->bRotationFollowsVelocity = true;
}
void AVictoryProjectile::PostInitializeComponents()
{
Super::PostInitializeComponents();
//correct rot follow vel
GetWorldTimerManager().SetTimer(this,
&AVictoryProjectile::CorrectRotationFollowVelocity,
0.1,
false
);
}
Dear Friends at Epic,
I was instructed to make this a new bug report
One Interesting Replication Issue I Cant Solve
When a projectile is initially spawned, it faces wrong direction, but on the next frame ( I know its one frame cause it was really hard to get this screen shot) the projectile corrects it orientation.
the odd thing, is that on the listen server (top left) the projectile shows up correctly. And this issue only occurs in multiplayer context. Single player is always correct.
so its some sort of initial replication issue, but I dont know how to fix it
Entire Source and Game On Drop Box
My entire game and code are on drop box right now in Nathan Lyer/VictoryGameMultiplayerTest, if you want to check out this issue in depth. However you might want to run a multiplayer game via 127.0.0.1 as Alexander reported issues with other multiplayer setups.
I spawn the projectile from Private/Character/VictoryDragonHumanCharacter.cpp Line 192
AVictoryDragonHuman::ServerFireProjectile_Implementation
Projectile class is VictoryProjectile
//SERVER
void AVictoryDragonHuman::ServerFireProjectile_Implementation(
FVector_NetQuantize10 Origin,
FVector_NetQuantizeNormal ShootDir)
{
//no current projectile class to spawn?
if(!CurrentVictoryProjectileBP) return;
//~~~~~~~~~~~~~~~~~~~~~~
//Spawninfo
FActorSpawnParameters SpawnInfo;
//SpawnInfo.bNoCollisionFail = true;
SpawnInfo.Owner = this;
SpawnInfo.Instigator = this;
//spawn creature
AVictoryProjectile* Projectile =
GetWorld()->SpawnActor(
CurrentVictoryProjectileBP,
Origin,
ShootDir.Rotation(),
SpawnInfo
);
if(Projectile) Projectile->InitVelocity(ShootDir);
}