void AProjectile::SpawnShootFX(const FVector& location, const FRotator& rotator, USceneComponent* component, FName name) { FRandomStream Stream; //random stream FRotator rotTemp = rotator; rotTemp = FRotator(rotTemp.Pitch, rotTemp.Yaw, Stream.FRandRange(-180, 180)); //randomly rotate the effect //spawn shooting sound FX UGameplayStatics::SpawnSoundAttached(ShootFX.ShootSound, component, name); //Spawn shooting particle effect UGameplayStatics::SpawnEmitterAttached(ShootFX.ShootFlash, component, name); }
void AProjectile::SpawnImpactFX(const FHitResult& Hit) { FRandomStream Stream; //random stream FRotator rotTemp = Hit.ImpactNormal.Rotation(); rotTemp = FRotator(rotTemp.Pitch, rotTemp.Yaw, Stream.FRandRange(-180, 180)); //randomly rotate the effect //impact effects sound spawn UGameplayStatics::SpawnEmitterAtLocation(this, ImpactFX.Effect, Hit.ImpactPoint, rotTemp, true); //spawn decal effect on impact position UGameplayStatics::SpawnDecalAttached(ImpactFX.DecalMaterial, FVector(ImpactFX.DecalSize, ImpactFX.DecalSize, 1.0F), Hit.GetComponent(), Hit.BoneName, Hit.ImpactPoint, rotTemp, EAttachLocation::KeepWorldPosition, ImpactFX.DecalHealth); }