Sega 500
1 / 55

Sega 500 - PowerPoint PPT Presentation

  • Uploaded on

Sega 500. Playing with the Camera. Jeff “Ezeikeil” Giles So far…. We’ve see that we can add a considerable degree of functionality to UT2003 just by the creation of a new game type. …However it still looks a lot like UT. Today.

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

PowerPoint Slideshow about 'Sega 500' - lanai

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Sega 500

Sega 500

Playing with the Camera

Jeff “Ezeikeil” Giles

So far
So far…

  • We’ve see that we can add a considerable degree of functionality to UT2003 just by the creation of a new game type.

    …However it still looks a lot like UT


  • We’re going to take our first steps towards fixing that.

  • We’re going to break the camera away from the player.

Behind view
Behind view

  • So far, we’ve seen that UT actually provides us with a degree of functionality already through the console

  • Just type in “Behindview 1”

Behind view2
Behind view

  • Yup, looks like I’m behind my character.

  • Typing “Behindview 0” resets the players view.

  • It’s a simple Boolean flag…and yes, “true” and “false” work also.

Behind view3
Behind view

  • So diving into the code we find it defined in PlayerController as:

    var bool bBehindView; // Outside-the-player view.

  • Hmmmm…... PlayerController …..that sounds familiar.

Behind view4
Behind view

  • It should…

  • If you recall from our custom game type, we were using controllers to access information in the pawn to figure out who killed who.

Behind view5
Behind view

  • We’ll talk about controllers and their various incarnations in a bit.

  • For now, we just need to know that ALL pawns have one.

Behind view6
Behind view

  • So, inside our HUD class, we’ve already learned how to access information stored inside any pawn.

  • Also that the HUD has a PawnOwner, and all pawns (which are sill alive) have a controller.

  • Hence, we should have access.

Behind view7
Behind view

  • Then, lets override the PostRender function and set bBehindview to true.

  • To the code…

Behind view8
Behind view

  • Hang-on! I don’t seem to have access via the controller.

Behind view9
Behind view

  • Well actually, you do.

  • Remember, UT is heavily dependant on inheritance and the Playercontroller is a child class of controller.

  • The answer is some type casting.

Behind view10
Behind view

  • Look closer at the inheritance structure

  • Well, nuts. How do we make sure that PawnOwner.controller is in fact a PlayerController.

  • We can’t just cast it now…

Behind view11
Behind view

  • Time to meet a new friend know as the Isa() function.

  • This function is defined in the Object class as:

    native(303) final function bool IsA( name ClassName );

Behind view12
Behind view

  • It simply returns true if this actor belongs to a named class.

  • Hey! Handy!

  • So how do we use it…

Behind view13
Behind view

function PostRender(canvas c)






  • This will cause the player to ALWAYS be drawn from behind.

  • To the code

What are controllers
What are controllers?

  • Well, that’s kind of neat…

  • So what then are controllers?

What are controllers1
What are controllers?

  • Controllers are non-physical actors that can be attached to a pawn to control its actions.

  • PlayerControllers are used by human players to control pawns, while

  • AIControllers implement the artificial intelligence for the pawns they control.

  • They take control of a pawn using their Possess() method, and relinquish control of the pawn by calling UnPossess().

What are controllers2
What are controllers?

  • Controllers receive notifications for many of the events occurring for the Pawn they are controlling.

  • This gives the controller the opportunity to implement the behavior in response to this event, intercepting the event and superceding the Pawn's default behavior.

What are controllers3
What are controllers?

  • To put this another way…

  • The Controller classes define how a pawn, or group of pawns, act, think and behave in their world.

  • More specific functionality is implemented in the child classes.

Behind view15
Behind view

  • Open the Controller class & give it a look. Here are *some* of the variables it looks after.

    var Pawn Pawn;

    var const int PlayerNum; // The player number - per-match player number.

    Var float SightCounter; // Used to keep track of when to check player


    Var float FovAngle; // X field of view angle in degrees, usually 90.

    var globalconfig float Handedness;

    var bool bIsPlayer; // Pawn is a player or a player-bot.

    var bool bGodMode; // cheat - when true, can't be killed or hurt

Behind view16
Behind view

//AI flags

var const bool bLOSflag; // used for alternating LineOfSight traces

var bool bAdvancedTactics; // serpentine movement between pathnodes

var bool bCanOpenDoors;

var bool bCanDoSpecial;

var bool bAdjusting; // adjusting around obstacle

var bool bPreparingMove; // set true while pawn sets up for a latent move

var bool bControlAnimations; // take control of animations from pawn (don't let pawn play

animations based on notifications)

var bool bEnemyInfoValid; // false when change enemy, true when LastSeenPos etc updated

var bool bNotifyApex; // event NotifyJumpApex() when at apex of jump

var bool bUsePlayerHearing;

var bool bJumpOverWall; // true when jumping to clear obstacle

var bool bEnemyAcquired;

var bool bSoaking; // pause and focus on this bot if it encounters a problem

var bool bHuntPlayer; // hunting player

var bool bAllowedToTranslocate;

var bool bAllowedToImpactJump;

var bool bAdrenalineEnabled;

Behind view17
Behind view

  • As you can see, it goes on.

  • So now that we know more about what controllers are, lets give the HUD another look.

  • If we kick open HUD.uc, one of customHUD’s parents…we see:

Behind view18
Behind view

var() PlayerController PlayerOwner;

var() Pawn PawnOwner;

var() PlayerReplicationInfo PawnOwnerPRI;

var() Console PlayerConsole;

  • Hey looky, there’s our PawnOwner object that we’ve been using to access the controller.

Behind view19
Behind view

  • …and right above it

    var() PlayerController PlayerOwner;

  • Giving us direct access to the owning player.

  • Notice that this is just for HUMAN players.

Behind view20
Behind view

  • Making some changes, we can condense our code to

    function PostRender(canvas c)





Behind view21
Behind view

  • And, it works!....yay me!

Custom controllers
Custom Controllers

  • Now that we know about how controllers access the pawns, it’s apparent that how we are setting the behindview is not very good object orientation.

    …It really should be done inside the controller.

Custom controllers1
Custom Controllers

  • So comment out that PostRender function. We don’t need it anymore.

  • Well create our own custom controller class to deal with this.

Custom controllers2
Custom Controllers

  • I’m just going to derive one off PlayerController and set the bBehindview to true in the defaults.

class CustomController extends PlayerController;





Custom controllers3
Custom Controllers

  • And in our game type we need specify that we want to use our new controller


  • That should do it…

  • To the Code.

Custom controllers5
Custom Controllers

  • What, I’m dead?

  • And I can’t respawn?

    Ok…What’s going on…

Custom controllers6
Custom Controllers

  • Look closer at the class tree.

  • We derived of Playercontroller

Custom controllers7
Custom Controllers

  • But there is a whole wack of stuff that UT needs to know about to make the game run which is missing…

  • Change the parent to xPlayer and give it a shot.

  • Back to the code

Custom controllers8
Custom Controllers

  • Uh, not quite…But at least it runs now.

  • We need to override one more function…well an event actually.

  • “Heh?” You say? “What’s an event?”

Custom controllers9
Custom Controllers

  • The "event" keyword has the same meaning to UnrealScript as "function". However, when you export a C++ header file from Unreal using "unreal -make -h", UnrealEd automatically generates a C++ -> UnrealScript calling stub for each "event".

Custom controllers10
Custom Controllers

  • The function we over ride is defined in playercontroller as:

    event PlayerCalcView(out actor ViewActor, out vector CameraLocation, out rotator CameraRotation )

  • With a rather long function definition.

Custom controllers11
Custom Controllers

  • So lets give this a shot…

class CustomController extends xPlayer;

event PlayerCalcView(out actor ViewActor, out vector CameraLocation,

out rotator CameraRotation )




Custom controllers12
Custom Controllers

  • Looks like it works…

  • But what’s all this boxy stuff?

  • Try moving…see what happens.

Custom controllers13
Custom Controllers

  • GAH!

  • My body’s running away!

  • That’s moderately disturbing.

Custom controllers14
Custom Controllers

  • This is an interesting side effect form not calling the super.

  • The new code:

class CustomController extends xPlayer;

event PlayerCalcView(out actor ViewActor, out vector CameraLocation,

out rotator CameraRotation )


super.PlayerCalcView(ViewActor, CameraLocation, CameraRotation );



Custom controllers15
Custom Controllers

  • And everything is right in the world.

  • We now have a 100%-can’t be change chase cam. It’s always in behind view.

  • Go ahead, try typing behindview into the console.

Custom controllers16
Custom Controllers

  • Notice that the screen flickers but instantly snaps back to the chase cam.

Custom controllers17
Custom Controllers

  • A bit about the PlayerCalcView event

    PlayerCalcView(out actor ViewActor, out vector CameraLocation, out rotator CameraRotation )

    • ViewActor: is which is passed in. Usually which one your looking at…but not necessarily.

    • CameraLocation: The point the world which you are viewing from.

    • CameraRotation: the cameras rotation in the world.

Custom controllers18
Custom Controllers

  • This gives us total control of the camera & where we view the world from.

  • If we don’t call the super and add of a few lines, we can track as though he’s on a security camera.

Custom controllers19
Custom Controllers

  • The new code:

event PlayerCalcView(out actor ViewActor, out vector CameraLocation,

out rotator CameraRotation )





CameraLocation.Y+=100; //so we don’t start inside our player


Custom controllers20
Custom Controllers

  • Notice how the camera tracks me from my start point…keeping me dead center I the screen.

Custom controllers21
Custom Controllers

  • This is cool! We can now do whatever we want to the camera. THROUGH CODE!

  • But there are a few things that we don’t have.

Custom controllers22
Custom Controllers

  • For example the player no longer pitches up or down…Always looking at the horizon.

  • That and the crosshair no longer indicates what we’re shooting at but remains fixed in the center of the screen on top of the player.

Custom controllers23
Custom Controllers

  • However these are all thing that we can change and override.

  • But that’s a story for another day.

On a side note however
On a side note however

  • There are 2 other calcview functions inside PlayerController which allow further manipulation of the camera.

    • CalcFirstPersonView

    • CalcBehindView

Next time
Next time

  • We’ll carry on with our manipulations of the camera system and see what other funkiness we can squeeze out of it.