Hi guys, I have a gameplay ability to fire a projectile, (multiplayer).
It works as follows:
- Play montage and wait for event, an animation notify will trigger an event at a certain point in the montage
- on event receive, only process on client, compute projectile transform using player camera etc
- call server function to spawn the projectile on the server, spawned deferred,
void UGA_RangedProjectile::Server_SpawnProjectile_Implementation(
const FTransform& ProjectileTransform
) {
SpawnProjectileWithTransform(ProjectileTransform);
}
void UGA_RangedProjectile::SpawnProjectileWithTransform(
const FTransform& ProjectileTransform
) {
...
ADProjectile* Projectile = GetWorld()->SpawnActorDeferred<ADProjectile>(
ProjectileClass,
ProjectileTransform,
GetOwningActorFromActorInfo(),
CurrentCharacter,
ESpawnActorCollisionHandlingMethod::AlwaysSpawn
);
Projectile->DamageEffectSpecHandle = DamageEffectSpecHandle;
Projectile->FinishSpawning(ProjectileTransform);
}
This works great, except when my character gets a buffed attack speed, which i am directly putting into the play rate of the anim montage, in this case (the higher the attack speed the worse), the projectile is correctly spawned on the server (begin play called with authority on the projectile actor), but SOMETIMES not on the client (no begin play called on the client).
I thought it might be due to the end ability being called too soon, interrupting it, but when i used a timer manager to delay End Ability, and even use a gating mechanism to only end the ability if the projectile has been spawned, it did not make a difference.
However if i put the end ability after the projectile spawn code (after Projectile->FinishSpawning()), it is able to spawn and replicate projectiles at the correct speed, but obviously ‘animation cancels’ to do so (which is not desired). Any help with this is greatly appreciated!!