Announcement

Collapse
No announcement yet.

Replicating decals spawns across a network

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Replicating decals spawns across a network

    Hello everyone....

    I want to ask whats the best way to spawn decals across a network?

    I don't think that there is any good way to replicate decals. The hit confirmation in my game is only by the server so I am using a unreliable netmulticast function that takes the hit location and normal and spawns the decals. Something like this.

    Code:
    void ABaseWeapon::SpawnImpactEffects_Implementation(const FHitResult& Impact)
    {
    	if (ImpactTemplate && Impact.bBlockingHit)
    	{
    		FHitResult UseImpact = Impact;
    
    		// trace again to find component lost during replication
    		if (!Impact.Component.IsValid())
    		{
    			const FVector StartTrace = Impact.ImpactPoint + Impact.ImpactNormal * 10.0f;
    			const FVector EndTrace = Impact.ImpactPoint - Impact.ImpactNormal * 10.0f;
    			FHitResult Hit = WeaponTrace(StartTrace, EndTrace);
    			UseImpact = Hit;
    		}
    
    		AFireHitImpact* EffectActor = GetWorld()->SpawnActorDeferred<AFireHitImpact>(ImpactTemplate, Impact.ImpactPoint, Impact.ImpactNormal.Rotation());
    		if (EffectActor)
    		{
    			EffectActor->SurfaceHit = UseImpact;
    			UGameplayStatics::FinishSpawningActor(EffectActor, FTransform(Impact.ImpactNormal.Rotation(), Impact.ImpactPoint));
    		}
    	}
    }
    Something like this is also used in the shooter game. I am calling this function as an unreliable net multicast. I also used another uint8 for passing to the client when the shots happen, for weapon animation weapon fx and stuff. Should I merge these to functionalists into 1 function?
Working...
X