UDN
Search public documentation:

ReplicationTornOff
日本語訳
中国翻译
한국어

Interested in the Unreal Engine?
Visit the Unreal Technology site.

Looking for jobs and company info?
Check out the Epic games site.

Questions about support via UDN?
Contact the UDN Staff

UE3 Home > Networking & Replication > Torn off pattern

Torn off pattern


Overview


This pattern is used when you want to stop replicating to an actor. The server will not replicate torn off actors to new clients who join afterwards. When an actor is torn off from the network, the event TornOff is executed.

Pawns


This pattern is used in Unreal Tournament for pawns, specifically when pawns die. When a pawn dies, pawns usually tend to play a death animation or become physics objects. During that time, it is no longer necessary to continue replicating anything to the client.

Pawn.uc
simulated event TornOff()
{
  // assume dead if bTearOff
  if (!bPlayedDeath)
  {
    PlayDying(HitDamageType,TakeHitLocation);
  }
}

simulated function PlayDying(class<DamageType> DamageType, vector HitLoc)
{
  GotoState('Dying');
  bReplicateMovement = false;
  bTearOff = true;
  Velocity += TearOffMomentum;
  SetDyingPhysics();
  bPlayedDeath = true;
  KismetDeathDelayTime = default.KismetDeathDelayTime + WorldInfo.TimeSeconds;
}

Ideally you should set bTearOff first on the server, so that it can then be replicated to the client. When the client receives the update to bTearOff it then executes TornOff(). This is similar to RepNotify in design.

Conclusion


This pattern is used when you want the server to stop replicating to actors to the client, when they can be fully simulated on the client without causing simulation problems. Other than when pawns die, other useful instances where this pattern can be useful are:
  • Projectiles that can be controlled by players for a set duration of time, after which the players lose control.
  • Client side effects which require replication for a set duration of time.