Catching up

September 16, 2009
by Nathan Whitehouse (nw08)

My name is Nathan Whitehouse, and I’m a sophomore at Hampshire doing an independent study on video game design in the Unity 3D environment (, with a focus on AI.

This is my first i3ci blog entry, but before this I started a blogger blog to follow my progress. Originally I was worried about the fact that i3ci blogs didn’t yet have security certificates, which might scare some people off, but it looks like that’s about to be fixed.

The old blog can be viewed here:

To summarize what I’ve done so far, however.

I’ve implemented two basic weapons which are able to fire with variable spread patterns, which the player can switch between at will; there are targets which have health and which can be destroyed. A lot of time has been spent trying to make sure all this basic stuff is optimized for future use; there are many easy methods to code the ability to switch between two weapons, for example, but many of them become complicated, confusing, or impossible if more weapons (and more variety in weapon function) is added later. So weapons, for example, are tagged and immediately placed into an array (variable right now, but once I know how big I’ll want it I’ll change it to builtin), and switching is done entirely by cycling through the array in a forloop.

Right now, what’s proving tricky is pausing the game. There seems to be no clear way to do it in the unity API, so each individual script needs to have a pause condition. Most rigidbody physics calculations can be stopped by changing the global ‘timeScale’ variable to zero. This does not, however, stop all types of physics, and update is still called in scripts, making it possible to continue to mouselook, for example. So in every script I’ve had to add in an if statement a check to see if the game is supposed to be paused. I’ve done research, and this seems to be the way to do it, although the trick is I suppose minimizing the number of times the conditional needs to be checked.

Helpful in this are Static Variables. A static variable is defined once, in any one script, yet can be accessed and changed from any other script. So here I have a static var called gamePaused. It’s only changed in one script right now, the GameStateController script, but any script can access it, so checking the variable is easy.

What’s giving me trouble is an error I just can’t seem to figure out. I’m going to bang away it at a little more before posting the whole thing, but essentially the cursor won’t seem to lock once it’s been unlocked if I try to use the same button to lock it as I do to unlock it (IE.

if(Screen.lockCursor == false){
Screen.lockCursor = true;

}if(Screen.lockCursor == true){
Screen.lockCursor = false;


) That’s essentially the code.

2 Responses to “Catching up”

  1.   MIKE Says:

    CheapTabletsOnline.Com. Canadian Health&Care.Best quality drugs.Special Internet Prices.No prescription online pharmacy. No prescription pills. Buy drugs online

    Buy:Lipitor.Zetia.Female Pink Viagra.Ventolin.Prozac.SleepWell.Buspar.Lipothin.Acomplia.Female Cialis.Advair.Seroquel.Lasix.Aricept.Cozaar.Wellbutrin SR.Amoxicillin.Nymphomax.Zocor.Benicar….

  2.   JEFF Says: Canadian Health&Care.No prescription online pharmacy.Best quality drugs.Special Internet Prices. High quality pills. Order drugs online

    Buy:Lipothin.Female Cialis.Benicar.Prozac.Lipitor.Lasix.Aricept.Seroquel.Zocor.Advair.Nymphomax.Buspar.Amoxicillin.Cozaar.Ventolin.Zetia.Acomplia.Female Pink Viagra.Wellbutrin SR.SleepWell….

Leave a Reply

You must be logged in to post a comment.