I'm a doctor, not a mechanic

Legacy:YawTeleporter

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to: navigation, search
UT :: Actor (UT) >> NavigationPoint (UT) >> Teleporter >> YawTeleporter (Custom)

A special Teleporter that makes the player always change yaw (after exit from YawTeleporter) to face the direction of the directional arrow of the YawTeleporter.

Code[edit]

To use this actor, subclass Teleporter with the following code. This class has been tested offline only. See Create A Subclass and Embedding Code for how to use this script.

//=============================================================================
// YawTeleporter. By Wormbo http://www.koehler-homepage.de/wormbo/ 
// Additional changes by AX000
// Makes actors always face the direction of the directional teleporter upon exit
//=============================================================================
class YawTeleporter extends Teleporter;
 
var UTTeleEffect T;
 
simulated function Destroyed()
{
	if ( T != None )
		T.Destroy();
	Super.Destroyed();
}
 
simulated function PostBeginPlay()
{
	LoopAnim('Teleport', 2.0, 0.0);
	T = spawn(class'UTTeleeffect');
	T.lifespan = 0.0;
}
 
// Accept an actor that has teleported in.
simulated function bool Accept( actor Incoming, Actor Source )
{
	local rotator newRot, oldRot;
	local pawn P;
 
	// Move the actor here.
	Disable('Touch');
	//log("Move Actor here "$tag);
	newRot = Incoming.Rotation;
	if ( bChangesYaw ) {
		oldRot = Incoming.Rotation;
		newRot.Yaw = Rotation.Yaw;
	}
 
	if ( Pawn(Incoming) != None ) {
		//tell enemies about teleport
		if ( Role == ROLE_Authority ) {
			P = Level.PawnList;
			While ( P != None ) {
				if ( P.Enemy == Incoming )
					P.LastSeenPos = Incoming.Location; 
				P = P.nextPawn;
			}
		}
		Pawn(Incoming).SetLocation(Location);
		if ( Role == ROLE_Authority || Level.TimeSeconds - LastFired > 0.5 ) {
			Pawn(Incoming).SetRotation(newRot);
			Pawn(Incoming).ViewRotation = newRot;
			LastFired = Level.TimeSeconds;
		}
		Pawn(Incoming).MoveTimer = -1.0;
		Pawn(Incoming).MoveTarget = self;
		PlayTeleportEffect( Incoming, false);
	}
	else {
		if ( !Incoming.SetLocation(Location) ) {
			Enable('Touch');
			return false;
		}
		if ( bChangesYaw )
			Incoming.SetRotation(newRot);
	}
 
	Enable('Touch');
 
	if ( bChangesVelocity )
		Incoming.Velocity = TargetVelocity;
	else {
		if ( bChangesYaw ) {
			if ( Incoming.Physics == PHYS_Walking )
				OldRot.Pitch = 0;
			Incoming.Velocity = Incoming.Velocity << OldRot;
			Incoming.Velocity = Incoming.Velocity >> NewRot;
(Incoming.Rotation);
		} 
		if ( bReversesX )
			Incoming.Velocity.X *= -1.0;
		if ( bReversesY )
			Incoming.Velocity.Y *= -1.0;
		if ( bReversesZ )
			Incoming.Velocity.Z *= -1.0;
	}	
 
	// Play teleport-in effect.
 
	return true;
}

Credits[edit]

Made by Wormbo.

Visible texture effect added by AX000.

History / Discussion[edit]

AX000: I wanted a teleporter that made the player always face the direction of the direction arrow when the player exited the teleporter. I asked Wormbo to make this.

Wormbo: I only changed the Teleporter script. I didn't compile or even test it, but I've heard of problems in network games. Whoever can solve these gets a cookie. :)

Mychaeel: What kind of network problems? (By the way, Teleporter is bStatic, so the visible animation of YawTeleporter probably doesn't play. Set bStatic=False and bNoDelete=True.)

Wormbo: As far as I've heard it the player's rotation isn't set correctly, but only in network games. I don't know if this occurs only on the clients or also on the server. Like I mentioned before: I never ha a compiled version of this teleporter.

Dante: Uhm, as far as it seems,

simulated function bool Accept( actor Incoming, Actor Source ) {
      return super.Accept( Incoming, None );
}

does the same, or did I miss some hidden stuff ;) ?

Wormbo: Sounds good. I'll have someone test it. :)

Wormbo: This was the last fix for this script. Have a look at DelayedTeleporter for a more flexible teleporter class.

Unfallzeuge Wormbo's script doesn't work with the newer build :( but the 2 lines code by Dante make a damn fine job if you need a teleporter with this characteristics

Fyfe: Dante's fix works for both UT and UT200*, it's the spawn effect part that only works in UT, UT200* already spawns an effect. The above code should refact to:

For UT:[edit]

//=============================================================================
// YawTeleporter. By Wormbo http://www.koehler-homepage.de/wormbo/ 
// Additional changes by AX000
// Makes actors always face the direction of the directional teleporter upon exit
//=============================================================================
class YawTeleporter extends Teleporter;
 
var UTTeleEffect T;
 
simulated function Destroyed()
{
    if ( T != None )
        T.Destroy();
    Super.Destroyed();
}
 
simulated function PostBeginPlay()
{
    LoopAnim('Teleport', 2.0, 0.0);
    T = spawn(class'UTTeleeffect');
    T.lifespan = 0.0;
}
 
// Accept an actor that has teleported in.
simulated function bool Accept( actor Incoming, Actor Source )
{
	return Super.Accept( Incoming, None );
}
 
DefaultProperties
{
	bStatic=False
	bNoDelete=True
}

For UT200*:[edit]

//=============================================================================
// YawTeleporter. By Wormbo http://www.koehler-homepage.de/wormbo/ 
// Additional changes by AX000
// Makes actors always face the direction of the directional teleporter upon exit
//=============================================================================
class YawTeleporter extends Teleporter;
 
// Accept an actor that has teleported in.
simulated function bool Accept( actor Incoming, Actor Source )
{
	return Super.Accept( Incoming, None );
}
 
DefaultProperties
{
	bNoDelete=True
	bStatic=False
}

Unless there are any objections, I'll drop this in place of the above. Unless someone sees the need for a seperate page for UT and UT200*


Category:Legacy Custom Class (UT)
Category:Legacy Class (UT)
Category:Legacy Refactor Me – possibly rename to YawTeleporter (UT) and use the Dante's tip to create YawTeleporter for UT2003