sega 500 n.
Skip this Video
Loading SlideShow in 5 Seconds..
Sega 500 PowerPoint Presentation

Sega 500

140 Vues Download Presentation
Télécharger la présentation

Sega 500

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Sega 500 Projecting a Crosshair Jeff “Ezeikeil” Giles

  2. The plan for today… • I know I promised that this week would be nearly exclusively on states, but this is just too cool to pass up. • And I get a simple demonstration of how to use states in our favour.

  3. The plan for today… • After having built all these 3rd person mods to UT is was quickly really apparent how difficult it is to effectively target enemy pawns in the game. • Not to mention the offset between the crosshair and the impact point.

  4. The plan for today… • Today we’re going to look at one fix possible fix to that. • By mapping a crosshair onto the terrain.

  5. The plan for today… • In effect we’re replacing the crosshair with a form of laser pointer. • Notice how it maps to the terrain?

  6. The plan for today… • …Oh…dude!...sign me up for some of that action! • This actually renders the game from the 3rd person quite playable and yield quite a different feel to the game.

  7. So what's going on? • UT 2003 comes with these really neat toys called projectors which dynamically map textures on to…well…whatever you want. • Although you may not know it, you’ve already seen these in action…a lot.

  8. So what's going on? • Heh? Where?

  9. The Bulldog Demo…

  10. Any Blast Mark…

  11. Any Shadow effect… There are also shadows projected from the trees, but they are hard to see when not animating.

  12. So what's going on? • In effect, this tool which is placeable in the editor, maps a texture onto an object in our world. It is not ray traced.

  13. So what's going on? • And for moving objects, like the bulldog or our pawn, we simply bind the projector to them. • It’s not really a difficult process, but there are some very Specific hoops to jump through.

  14. Getting Started… • I found messing with these things finicky enough that it’s a good idea to set on up in the editor first to get an idea of what's involved. • So…lets do that…

  15. A basic projector… • Once you’ve got a location set up for you projector, dig it out of the actors list and place it in the level. • I’m using a Dynamic projector.

  16. A basic projector… • Once you’ve got it in the leveland pointing in the direction you want, we need to tell it what to project and how far. • Yup, you guess it, time to set up some defaults…

  17. A basic projector… • As you can see, we have quite a list to choose from. • We’re only interested in 3 sections right now: ProjTexture, FOV, and FameBufferBlending.

  18. A basic projector… • First off, we’re going to setup the texture we intend to use which should be enough to cause something to show up…

  19. A basic projector… • Yup something does… A yellow box…and a black diamond on the wall…..grrrrreat. • Actually it IS projecting what it’s supposed to, we just have to yutz with a few more things.

  20. A basic projector… • Starting with the FOV… • The FOV defaults to 0, which is really bad since we need a positive number to define to calculate HOW to project it. • Any number between 0 and 100 should be good. Outside this range is going to cause weird results.

  21. A basic projector… • When I set mine to 10 it was is enough to get it to show up. • But it also caused this blue box to appear and expand the yellow one.

  22. A basic projector… • Looking a this blue box in the top viewport, we see that it is conical in shape…looking quite a bit like a view fustrum, wouldn’t you say? • Actually…Exactly like a view fustrum.

  23. A basic projector… • And after playing with the FameBufferBlending, we should have a working projector… • Mine is set to PB_Add.

  24. A basic projector… • And checkout what happens when we run it… • In 1st person it projects onto our weapon model…

  25. A basic projector… • And in 3rd person, it projects on any pawn or world object that happens to be in front of it. • Is that sweet or what!

  26. A basic projector… • And there you have it, a basic projector in the editor. • Now its time to go about binding one of these to the player.

  27. Binding a projector to a pawn… • One thing to note, I’m just expanding on the mario cam ( lesson 14 ) in this example. But there’s no reason why you couldn’t adapt this to any game type…like the Max Payne cam for example.

  28. Binding a projector to a pawn… • The first thing to realize is exactly what we need to build this. • I followed the example used in the bulldog. • One Pawn, one dynamic projector.

  29. Binding a projector to a pawn… • After looking a the BulldogHeadlight projector, it’s pretty apparent that there’s not really a lot for us to do here other than set up some defaults. • So I just created my own class from and borrowed the defaults from the BulldogHeadlight. We’ll customize them in a moment.

  30. Binding a projector to a pawn… class Target extends DynamicProjector; function Tick(float Delta) {} defaultproperties { DrawScale=0.65 bHidden=true FrameBufferBlendingOp=PB_Add ProjTexture=Texture'VehicleFX.Projected.BullHeadlights' FOV=30 MaxTraceDistance=2048 bProjectOnUnlit=True bGradient=True

  31. Binding a projector to a pawn… bProjectOnAlpha=True bLightChanged=True bHardAttach=True bProjectActor=True bProjectOnParallelBSP=True bClipBSP=True RemoteRole=ROLE_None } • Pretty much straight from BulldogHeadlight, just so we have our projector to work with.

  32. Binding a projector to a pawn… • So, now’s the time to bind it to the pawn. • After thinking about this in terms of good OOP, seeing as all the information that we need is dependant on the the pawn class, it makes sense to create our own.

  33. Binding a projector to a pawn… • Now the creation part is easy, just derive one from xPawn, inside which we’ll create an instance of our projector. class MarioPawn extends xPawn; var Target crosshair;

  34. Binding a projector to a pawn… • Erm...hang on a sec. • How are we going to the UT to use OUR pawn and not the default xPawn class?

  35. Binding a projector to a pawn… • Well, since we’re using the old code for our mariocam.uc, we already have a custom playercontroller built and implemented for us. • Thus, we just tell the Playercontroller what type pawn it needs to use.

  36. Binding a projector to a pawn… DefaultProperties { …<SNIP!>… PawnClass=class'eze.marioPawn' } • UT should now know to use our pawn… That wasn’t so bad now was it?

  37. Binding a projector to a pawn… • Now, we just spawn our projector into existence when the player enters the game. function PostBeginPlay() { Super.PostNetBeginPlay(); crosshair = spawn(class'Target', self,,location ); }

  38. Binding a projector to a pawn… • And as mentioned in the Projector class, we have to do a custom tick function so that it will be bound to our player. function Tick(float deltatime) { super.Tick(deltatime); crosshair.DetachProjector(); //order is important crosshair.setlocation(location); crosshair.AttachProjector(); }

  39. Binding a projector to a pawn… • And if we run it now, we get some headlights that follow use around but don’t orient with the pawn. Ed-209: “Drop you weapon! You have 3 seconds to comply”

  40. Binding a projector to a pawn… • This is actually easy to fix, there’s a function built into all the actors in the game called setrotation() which does just as it’s name promises. • Remember that we can’t do an assignment because a rotation is a constant…we HAVE to call the function.

  41. Binding a projector to a pawn… • Adding one line to our tick function in the pawn class solves that problem… …sort of… crosshair.SetRotation(rotation);

  42. Binding a projector to a pawn… • It rotates with me no problem…but we don’t pitch… “No problem Miss, I’ll get your cat out of that tree.”

  43. Binding a projector to a pawn… • OK, so if we look back at the player controller class, we’ve made the changes to the AdjustAim function to unlock the fire axis…and it DOES work…we can shoot up.

  44. Binding a projector to a pawn… • What happened is that we grabbed the pawn rotation…which doesn’t have a pitch value. • The pitch value comes from the view rotation.

  45. Binding a projector to a pawn… • Right…Right… Right…I remember that now… • Should fix the problem! crosshair.SetRotation( GetViewRotation()) ;

  46. Binding a projector to a pawn… • Uh…nope…same problem… • The Pawn class comes with a GetViewRotation function, look at how its defined…

  47. Binding a projector to a pawn… • Ok, That looks fine…getting the view rotation from the controller…lets look there. simulated function rotator GetViewRotation() { if ( Controller == None ) return Rotation; return Controller.GetViewRotation(); }

  48. Binding a projector to a pawn… function rotator GetViewRotation() { return Rotation; } • OK, this should work…what the heck?

  49. Binding a projector to a pawn… • Look back at what the pawn class asked for…the controller rotation…we are a player controller….we’re not looking in the right place yet. • So in Player controller…

  50. Binding a projector to a pawn… function rotator GetViewRotation() { if ( bBehindView && (Pawn != None) ) return Pawn.Rotation; return Rotation; } • In player controller, we find that if we’re using behind view, our Pawn rotation gets returned…locking our axis up…DOH!