Cogito, ergo sum


From Unreal Wiki, The Unreal Engine Documentation Site
Jump to: navigation, search

Movers that rotate in the process of opening or closing (doors, for instance) don't work well in network games; clients may see those movers rotated in ways that don't match their actual rotation on the server. The following class, presumptuously called FixedMover, fixes that problem. (See Embedding Code for how to use it in your maps.)

class FixedMover extends Mover;
var int RealRotationYaw;
var int RealRotationPitch;
var int RealRotationRoll;
replication {
  reliable if (Role == ROLE_Authority)
    RealRotationYaw, RealRotationPitch, RealRotationRoll;
simulated event Timer() {
  // first problem: rotators not replicated correctly
  if (Role < ROLE_Authority) {
    RealRotation.Yaw   = RealRotationYaw;
    RealRotation.Pitch = RealRotationPitch;
    RealRotation.Roll  = RealRotationRoll;
  // second problem: rotation not taken into account when updating position
  if (RealRotation != Rotation)
    bClientPause = true;
  if (Role == ROLE_Authority) {
    RealRotationYaw   = RealRotation.Yaw;
    RealRotationPitch = RealRotation.Pitch;
    RealRotationRoll  = RealRotation.Roll;