Tuesday, September 23, 2014

FPS, Part one.

In a new recurring segment, we'll be looking at the various mechanics of a First Person Shooter.


We start with (well, really an environment, but we'll skip that for now) our character controller and camera, which I've chosen to scale tiny, and allowing the hanger to now become a palace. This will of course require us to increase the run speed and jump height, as exploration shouldn't be tedious.


Here we see the character controller and camera (suspended in mid-air) in the enlarged hanger. And on the other side of the car, a basic GUI:

var crosshairTexture : Texture2D;
var position : Rect;

function Start()
{
        position = Rect( ( Screen.width - crosshairTexture.width ) / 2
Screen.height - crosshairTexture.height ) / 2crosshairTexture.widthcrosshairTexture.height );
}

function OnGUI()
{
    GUI.DrawTexture(positioncrosshairTexture);    
}


We declare some variables, a 2D texture asset and a position, enter the function, establish the position as centering the width and height of the asset across the screen, another function to match the texture-object to the position, and...


...It's like we've killed something already.


What are those exploding missiles doing there? I hope I figure out a way to figure out how to explain those javascripts before our next episode of...

For My Eyes Only -or- How I Learned to Stop Worrying and Love the Blog.

No comments:

Post a Comment