I love the smell of UnrealEd crashing in the morning. – tarquin

Legacy:RotatingMover

From Unreal Wiki, The Unreal Engine Documentation Site
Revision as of 09:00, 2 April 2010 by Claudius (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
UT :: Actor (UT) >> Brush >> Mover (UT) >> RotatingMover

A RotatingMover continuously revolves with its set RotationRate. Start the rotation by triggering it, stop it by untriggering it. (In other words, when a player starts touching a Trigger, the RotatingMover starts moving, and stops when the player leaves the trigger's radius.) Unfortunately, this kind of mover doesn't work online.

If you're trying to create a simple, constantly spinning object, you do not need to set the mover to "RotatingMover" at all. Rather, you can set Object -> InitialState to None, and then under Movement, set bFixedRotationDir to true, Physics to PHYS_Rotating, and then configure your desired rotation values under RotationRate.

If you want to use a mover that changes its rotation along its normal movement, just use a normal mover instead.

Network Fix[edit]

Unfortunately the RotatingMover class doesn't work in online games; on clients, the mover stands still. The following subclass fixes that. See Embedding Code for how to get it into your maps.


Note: the reason why the stock RotatingMover class isn't functioning online lies in the replication definition of the Rotation variable in the Actor class, which causes the rotation of the mover to be replicated only initially, since its RemoteRole == ROLE_SimulatedProxy. To have the rotation replicate continuously, change the RotatingMover's RemoteRole to ROLE_DumbProxy. Contrary to its parent, the RotatingMover isn't simulating anything on the client, so it is safe to make this change. As variables are replicated at the end of each tick and the rotation is only changed once a tick, there should be no loss of rotation information from server to client (apart from loss due to vector compression, native replication decisions,...).

However, as most rotating movers are used mainly decoratively, you may want to save on bandwidth used for the rotation replication, by using the subclass instead.


This class also adds a new bEnabled property in the RotatingMover section of the property sheet. Use it to determine whether the mover starts automatically when the game is started or has to be triggered to start.

// ============================================================================
// FixedRotatingMover
// Created 2002 by Mychaeel <mychaeel@beyondunreal.com>
//
// Fixed incompatibility of RotatingMover in network games.
// ============================================================================
 
 
class FixedRotatingMover extends RotatingMover;
 
 
// ============================================================================
// Replication
// ============================================================================
 
replication {
 
  reliable if (Role == ROLE_Authority)
    bEnabled;
  }
 
 
// ============================================================================
// Variables
// ============================================================================
 
var(RotatingMover) bool bEnabled;
 
 
// ============================================================================
// BeginPlay
// ============================================================================
 
function BeginPlay();
 
 
// ============================================================================
// Tick
// ============================================================================
 
simulated function Tick(float TimeDelta) {
 
  if (bEnabled)
    SetRotation(Rotation + RotateRate * TimeDelta);
  }
 
 
// ============================================================================
// Trigger
// ============================================================================
 
function Trigger(Actor ActorOther, Pawn PawnInstigator) {
 
  bEnabled = true;
  }
 
 
// ============================================================================
// UnTrigger
// ============================================================================
 
function UnTrigger(Actor ActorOther, Pawn PawnInstigator) {
 
  bEnabled = false;
  }

In UnrealEd 2.0, the above will not appear when you right-click the Add Mover button. Instead, create a subclass of Mover and use the code below. The right-click of the Add Mover button only seems to gather the subclass of Mover, but not subsequent subclasses thereof. See Embedding Code for how to get it into your maps.

//=============================================================================
// FixedRotatingMover.
// Created 2002 by Mychaeel <mychaeel@beyondunreal.com>
// Modified 2002 by Occam <sm_zero@hotmail.com>
//=============================================================================
class FixedRotatingMover extends Mover;
 
var() rotator RotateRate;
 
// ============================================================================
// Replication
// ============================================================================
 
replication {
 
  reliable if (Role == ROLE_Authority)
    bEnabled;
  }
 
 
// ============================================================================
// Variables
// ============================================================================
 
var(FixedRotatingMover) bool bEnabled;
 
 
// ============================================================================
// BeginPlay
// ============================================================================
 
function BeginPlay();
 
 
// ============================================================================
// Tick
// ============================================================================
 
simulated function Tick(float TimeDelta) {
 
  if (bEnabled)
    SetRotation(Rotation + RotateRate * TimeDelta);
  }
 
 
// ============================================================================
// Trigger
// ============================================================================
 
function Trigger(Actor ActorOther, Pawn PawnInstigator) {
 
  bEnabled = true;
  }
 
 
// ============================================================================
// UnTrigger
// ============================================================================
 
function UnTrigger(Actor ActorOther, Pawn PawnInstigator) {
 
  bEnabled = false;
  }

Please note the mover's InitialState must be set to None in order for the Triggering function to work properly. Any other setting will mean the mover can not be triggered on in-game. Having the mover's InitialState set to None gives a "TriggerControl" effect (While the trigger is activated, the mover is enabled).