I am struggling to Get my event to stop every time on my weapons this is what i have implemented.
Mouse pressed starts weapon fire and mouse released stops fire.
weapon executes Fire();
that contains PlayWeaponFireAudio();
function checks if IsLocallyControlled and sets event to 1P or 3P on result
i then only set instance and play if instance is not valid as its a looping event
if(!EventInstance.Instance->isValid())
{
EventInstance = UFMODBlueprintStatics::PlayEventAtLocation(GetWorld(), CurrentFireEvent, GetActorTransform(), true);
}
UFMODBlueprintStatics::EventInstanceSetTransform(EventInstance, GetActorTransform());
i then use the same function in the MutiFire();
then when mouse is released i execute StopLoopedWeaponFireAudio()
i stop it locally with
UFMODBlueprintStatics::EventInstanceStop(EventInstance, true);
EventInstance.Instance = nullptr;
then run a server event that calls a multicast to stop the event with
UFMODBlueprintStatics::EventInstanceStop(EventInstance, true);
EventInstance.Instance = nullptr;
can anyone see any issues with the way i am doing it?
EventInstance is replicated
void AProjectileWeapon::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME(AProjectileWeapon, EventInstance);
}