Sega 500
Download
1 / 55

Sega 500 - PowerPoint PPT Presentation


  • 100 Views
  • Uploaded on
  • Presentation posted in: General

Sega 500. Playing with the Camera. Jeff “Ezeikeil” Giles jgiles@artschool.com http://gamestudies.cdis.org/~jgiles. 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.

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

Download Presentation

Sega 500

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

Playing with the Camera

Jeff “Ezeikeil” Giles

jgiles@artschool.com

http://gamestudies.cdis.org/~jgiles


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

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

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


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 view


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 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 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 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 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 view

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

  • To the code…


Behind view

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


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 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 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 view

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

  • Hey! Handy!

  • So how do we use it…


Behind view

function PostRender(canvas c)

{

super.PostRender(c);

if(pawnowner.Controller.IsA('playercontroller'))

playercontroller(pawnowner.Controller).bBehindView=true;

}

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

  • To the code


Behind view


What are controllers?

  • Well, that’s kind of neat…

  • So what then are controllers?


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 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 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 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 floatSightCounter;// Used to keep track of when to check player

    visibility

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

    var globalconfig floatHandedness;

    varbool bIsPlayer;// Pawn is a player or a player-bot.

    varboolbGodMode;// cheat - when true, can't be killed or hurt


Behind view

//AI flags

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

varbool bAdvancedTactics;// serpentine movement between pathnodes

varbool bCanOpenDoors;

varbool bCanDoSpecial;

varbool bAdjusting;// adjusting around obstacle

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

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

animations based on notifications)

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

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

varbool bUsePlayerHearing;

varbool bJumpOverWall;// true when jumping to clear obstacle

varbool bEnemyAcquired;

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

varbool bHuntPlayer;// hunting player

varbool bAllowedToTranslocate;

varbool bAllowedToImpactJump;

varbool bAdrenalineEnabled;


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 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 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 view

  • Making some changes, we can condense our code to

    function PostRender(canvas c)

    {

    super.PostRender(c);

    playerowner.BehindView(true);

    }


Behind view

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


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 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 Controllers

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

class CustomController extends PlayerController;

defaultproperties

{

bBehindView=true;

}


Custom Controllers

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

    PlayerControllerClassname="eze.CustomController"

  • That should do it…

  • To the Code.


Custom Controllers


Custom Controllers

  • What, I’m dead?

  • And I can’t respawn?

    Ok…What’s going on…


Custom Controllers

  • Look closer at the class tree.

  • We derived of Playercontroller


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 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 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 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 Controllers

  • So lets give this a shot…

class CustomController extends xPlayer;

event PlayerCalcView(out actor ViewActor, out vector CameraLocation,

out rotator CameraRotation )

{

bBehindView=true;

}


Custom Controllers

  • Looks like it works…

  • But what’s all this boxy stuff?

  • Try moving…see what happens.


Custom Controllers

  • GAH!

  • My body’s running away!

  • That’s moderately disturbing.


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 );

bBehindView=true;

}


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 Controllers

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


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 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 Controllers

  • The new code:

event PlayerCalcView(out actor ViewActor, out vector CameraLocation,

out rotator CameraRotation )

{

ViewActor=self;

bBehindView=true;

CameraLocation=Location;

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

}


Custom Controllers

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


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 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 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

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

    • CalcFirstPersonView

    • CalcBehindView


Next time

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


ad
  • Login