|
Overhead View
Mod Code : Tim
Mod Text : Tim
20 November 1998
//=============================================================================
// Overhead Player View - This is a new player class that will modify the
// player's view to make it overhead. It features an adjustable zoom levels.
// See the end of the document for information on how to use this in your
// levels, or just play unreal levels with it.
//=============================================================================
class Overhead expands MaleTwo;
var int zoom; // The actual distance from the user's head
var int zoomlevel; // The zoom level, the zoom number the user is in
// An exec funtion is one that you can call from the console or whenever the
// user pushes a key. This particular exec function adjusts the zoom. To make
// an exec function work, it has to be in the player class, you can't put an exec
// in to a weapon or an item. This function can be called just like a regular function
// or while in play. To use an exec funtion, simply put exec before function like I
// did. Thats it!
exec function azoom()
{
// These are case handling techniques. Each is basically the same
// I didn't think there was a select case routine in UScript, if there
// is, this can be drastically shortened.
if(zoomlevel==0) { // If the zoom level is at 0
zoomlevel=1; // Make the zoom level 1
zoom = 250; // Set the distance from the player to 250
clientmessage("100% Zoom Level"); // Show a message to the player
return;
} else if(zoomlevel==1) { // The other lines are basically the same
zoomlevel=2;
zoom = 125;
clientmessage("200% Zoom Level");
return;
} else if(zoomlevel==2) {
zoomlevel=3;
zoom = 62;
clientmessage("400% Zoom Level");
return;
} else if(zoomlevel==3) {
zoomlevel=4;
zoom = 125;
clientmessage("200% Zoom Level");
return;
} else if(zoomlevel==4) {
zoomlevel=5;
zoom = 250;
clientmessage("100% Zoom Level");
return;
} else if(zoomlevel==5) {
zoomlevel=6;
zoom = 500;
clientmessage("50% Zoom Level");
return;
} else if(zoomlevel==6) {
zoomlevel=7;
zoom = 750;
clientmessage("25% Zoom Level");
return;
} else if(zoomlevel==7) {
zoomlevel=0;
zoom = 250;
clientmessage("50% Zoom Level");
return;
}
}
// As a note, i set this up like this so there are repitions so
// that when you cycle through zooms, you actually follow some
// logical sequence, first zoom in then zoom out, etc.
// PostBeginPlay is called when the player is initialized.
// The only diference is that I made mouselook disabled
// due to the fact that its VERY hard to control, and
// I set some variables up
event PostBeginPlay()
{
Super.PostBeginPlay();
bAlwaysMouseLook = false; // Never Mouse Look
bSnapToLevel = false; // Basically no aim-up/down
zoom = 250; // Set the starting zoom to 250
zoomlevel = 1; // Make the starting zoomlevel 1
if (Level.LevelEnterText != "" )
ClientMessage(Level.LevelEnterText);
if ( Level.NetMode != NM_Client )
{
HUDType = Level.Game.HUDType;
ScoringType = Level.Game.ScoreboardType;
MyAutoAim = FMax(MyAutoAim, Level.Game.AutoAim);
}
bIsPlayer = true;
DodgeClickTime = FMin(0.3, DodgeClickTime);
EyeHeight = BaseEyeHeight;
if ( Level.Game.IsA('SinglePlayer') && (Level.NetMode == NM_Standalone) )
FlashScale = vect(0,0,0);
}
// PlayerCalcView is called to determine the location of the camera relative
// to the player. I made it so the camera is above the player
event PlayerCalcView( out actor ViewActor, out vector CameraLocation, out rotator CameraRotation )
{
local vector View,HitLocation,HitNormal;
local float ViewDist, WallOutDist;
ViewActor = Self; // View Yourself, otherwise you don't see yourself
bBehindView = true; // This doesn't mean what it says, it means we're basically viewing from out of the player
CameraLocation = Location; // Set camera to player location
CameraLocation.Z += EyeHeight; // Raise camera by eye-height
CameraLocation += WalkBob; // Move the camera by a set bob
// The next line is important!!! It raises the camera by a set height
CameraLocation.Z += zoom;
// As of this point, the camera is 250 feet in the air, but still facing the
// direction of the player. So, we gotta tilt the camera down. We do this
// by setting the CameraRotation. As you can see, we set the rotation to
// 0,0,-50. The first number is the tilt adjustment, the second is the
// left/right adjustment, the last is the up/down adjustment. Therefore, we
// adjust the up/down by 90 degrees downward, -50 unreal units.
CameraRotation = rotator(vect(0,0,-50)); // Point the camera downward
// Rotator here just converts a vector in to a rotation. A vector is something like
// the player's location, a rotator is something like the direction the player
// looks.
// Vect here turns three numbers in to a vector, the three being X, Y, and Z
}
defaultproperties
{
}
//=======================================================================
// Great. Now you know how to make a overhead camera. You're probably
// feeling smug, right? You're not done...
// To be this overhead guy in a level, you have to do this:
// Locate the section [defaultplayer] in your Unreal.ini. Change the class
// to whatever class you just made (its going to be in the form of package.overhead)
//
// OR, a way easier method is to start up unreal and type tab, then:
// open x?class=package.overhead, where x is a map, and package is the package
//
// If you want to use the adjustable zoom, start the game, then type tab,
// then: 'set input x azoom' without the quotes, where x is a key.
// a, 8, NumPad8, PageDown, and Down are all acceptable keys.
//
// Have fun!
//=========================================================================
Opinions on this article, love it, hate it? - feedback
|