Presentation is loading. Please wait.

Presentation is loading. Please wait.

Sega 500 Playing with the Camera Jeff “Ezeikeil” Giles

Similar presentations


Presentation on theme: "Sega 500 Playing with the Camera Jeff “Ezeikeil” Giles"— Presentation transcript:

1 Sega 500 Playing with the Camera Jeff “Ezeikeil” Giles jgiles@artschool.com http://gamestudies.cdis.org/~jgiles

2 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

3 Today We’re going to take our first steps towards fixing that. We’re going to break the camera away from the player.

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

5 Behind view

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

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

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

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

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

11 Behind view Then, lets override the PostRender function and set bBehindview to true. To the code…

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

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

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

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

16 Behind view It simply returns true if this actor belongs to a named class. Hey! Handy! So how do we use it…

17 Behind view This will cause the player to ALWAYS be drawn from behind. To the code function PostRender(canvas c) { super.PostRender(c); if(pawnowner.Controller.IsA('playercontroller')) playercontroller(pawnowner.Controller).bBehindView=true; }

18 Behind view

19 What are controllers? Well, that’s kind of neat… So what then are controllers?

20 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().

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

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

23 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

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

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

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

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

28 Behind view Making some changes, we can condense our code to function PostRender(canvas c) { super.PostRender(c); playerowner.BehindView(true); }

29 Behind view And, it works!....yay me!

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

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

32 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; }

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

34 Custom Controllers

35 What, I’m dead? And I can’t respawn? Ok…What’s going on…

36 Custom Controllers Look closer at the class tree. We derived of Playercontroller

37 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

38 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?”

39 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".

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

41 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; }

42 Custom Controllers Looks like it works… But what’s all this boxy stuff? Try moving…see what happens.

43 Custom Controllers GAH! My body’s running away! That’s moderately disturbing.

44 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; }

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

46 Custom Controllers Notice that the screen flickers but instantly snaps back to the chase cam.

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

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

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

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

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

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

53 Custom Controllers However these are all thing that we can change and override. But that’s a story for another day.

54 On a side note however There are 2 other calcview functions inside PlayerController which allow further manipulation of the camera. CalcFirstPersonView CalcBehindView

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


Download ppt "Sega 500 Playing with the Camera Jeff “Ezeikeil” Giles"

Similar presentations


Ads by Google