The perfect jump: testing techniques for Jumping in Unity3D

In a physics-based engine, there’s many ways to make a character “jump”. For my 7-day FPS entry, I’m trying to work out the perfect jump for my gameplay. Easier said than done. I’m struggling…

Before I go looking for feedback and suggestions, I thought it would help to make a demo showing the things I’ve been trying-out.

Unity webplayer link to try the examples below

Instructions: wait till you land on skyscraper, then hit a number key to select a jump type, and get jumping (spacebar).

Note: if you fall, no problem, it’ll auto-respawn you after a couple of seconds of falling

Continue reading

Useful Links for the 2013 7dfps

Just gathering links here as I find them or remember them … useful things on FPS design, FPS coding, FPS art, etc.

(I’ve never written an FPS before, so … everything/anything in the way of research is useful!)



Level design

Assets / Art

  • – Free, high-quality fonts that (unlike most free fonts sites) aren’t “mostly stolen from somewhere else”, nor “not free, but advertised as free, so they can charge you later”
  • – Marcel’s excellent resource site for textures so you can DIY your models and texturing…

FPS Controller design

Specific to my game:

Assets for city-building in Unity

Unity bugfixes

Things I had to do to fix Unity long-standing bugs (that Unity has declared they’ll never fix). Most of these copy/pasted from my “Fix Unity Bugs” folders in other Unity projects ;)…

  • Customize GameObject to add: Find a specific Component on “the nearest ancestor that has one”
  • Customize GameObject to add: When creating a game object, always place it at 0,0,0, instead of “in the middle of nowhere, randomly”
  • Fix fonts so that they DO NOT render through walls (Unity makes everything in your scene transparent-to-text)
  • Auto-rescale all textures on scaled objects (Unity’s editor won’t allow you to scale a single object without scaling its fixed-size, tiling texture (and without breaking all your other objects) – but Unity source code strangely does allow it)

Make an FPS in 7 Days – Game idea: “Metamorphosis”

Next week is the 7DFPS challenge – design, code, ship a game in 7 Days, on the theme of “first person shooter”. I want to do something unique and interesting. Here’s one of my ideas.

(if you like this idea, please re-tweet this to vote for it – I’ll decide which to do based on which one(s) people like most) Other ideas: “Runners”, “Follow”)

Title: “Metamorphosis”

Premise: what makes an FPS unique/special among games is the visceral, immersive nature.

But our FPS’s today all project the same, boring, 1:1 flat rectangle as our window on the world.

What if we had eyes on the side of our head? (a la most herbivores – you can see to both sides, and halfway behind you – but have a blindspot dead-ahead. This is why some birds flick their heads left and right all the time – they physically can’t look directly ahead!)

What if you were a Beholder – with 360 simultaneous vision. Looking ahead, behind, up and down all at once?

What does the world look like when your camera is 2 inches off the ground? (a rat’s-eye-view) … or upside-down, attached to the ceiling? (a spider’s…)

Core gameplay

In Metamorphosis, you start in a lab with one way out: a small mouse-hole in the skirting-board. A theft gone wrong, a wizard about to catch you “in flagrante”. You have only one chance: a giant bubbling flask labelled “Rat”. You gobble the potion, dive through the hole, and escape.

…but now you’re a rat, loose in a dungeon full of nasties. Absolutely everything out there is bigger, meaner, and (often) uglier than you. And sadly: loot won’t be much good, since you’re too small to wear armour, and have no hands to hold a sword.

Special effects

It’s a dungeon-hack with a difference: you’re looking for magic potions that metamorphose you into new and useful creatures. When you metamorphose, everything changes:

  • the lighting (some creatures see by light, bats echo-locate and see only monochrome, other creates have infra-vision/heat-sensitive vision)
  • the viewpoint (high, low, upside-down)
  • the number of simultaneous “cameras” (one per eyeball…)
  • the “lens shape” of each eyeball (normal, fisheye, warped, 360-degrees…)
  • your strength/speed/vulnerability (heavy/light, low hitpoints / high hitpoints, regeneration…)
  • movement abilities (walk, jump (rats jump so high they almost fly…), fly, wall-walk, etc)


An old friend of mine wrote a real-time 360-degree FPS projection 15 years ago, and kindly dug out his original source code + demo app for me. With his permission, I’ll post it here ASAP, but suffice it to say: this stuff is doable, it may sound a bit crazy, but I’ve experimented with it (a little) before.

Upgrades and weapons

…entirely dictated by the creature you’re currently polymorphed into.


I like this idea because:

  • …polymorphing is fun.
  • …there’s historically been very little experimentation with FPS cameras – the best you can hope for is some post-processing screen effets (depth of field, over-saturation, blur, desaturation)

Make an FPS in 7 Days – Game idea: “Runners”

Next week is the 7DFPS challenge – design, code, ship a game in 7 Days, on the theme of “first person shooter”. I want to do something unique and interesting. Here’s one of my ideas.

(if you like this idea, please re-tweet this to vote for it – I’ll decide which to do based on which one(s) people like most) Other ideas: “Follow”, “Metamorphosis”)

Title: “Runners”

Premise: what makes an FPS unique/special among games is the visceral, immersive nature. How many Oculus Rift games are not first-person?

One thing FPS’s should be particularly good at is wish-fulfillment. Well, something I’ve “wished” I could do ever since seeing the opening sequence of The Matrix … is superhuman jumps from rooftop to rooftop. (YouTube: the ‘jump’ program and YouTube: the opening sequence)

(I especially like the second clip – this is the point at which we first get proof that the film can’t quite be real; it’s the first leap down the rabbit-hole…)

Core gameplay

Runners is simply an excuse to do desperate, death-defying, running jumps from rooftop to rooftop, while being shot at (and shooting back).

That’s it!

Challenges to the player

Moment to moment during the game, the player has the following decisions:

  1. Big jumps require big runups; you get faster the longer you run (Super Mario Bros stylee). Better plan your run-up, and don’t chicken-out and slowdown at the last minute!
  2. It’s easy to stand-still and snipe: so we make you invulnerable while in mid-air, and create lots of obstacles on the rooftops, that prevent “easy” shots from a distance
  3. You can’t jump forever (remember the bad old days of deathmatch quake bunnyhopping? Ugh). You have a fatigue meter that forces you to periodically stop and hide while you get your breath back
  4. “Guns. Lots of guns” – long distance, wide-open spaces, enclosed target areas? This is a perfect excuse for overblow weapons of insane destruction. Remember Syndicate’s supremely over-the-top Gauss Gun? Oh yeah!

Decisions, decisions

Three conflicting tensions (no upgrades in this one! Just choice of weapons):

  1. Movement: speed, jump-distance, acceleration (run-ups) … heavy weapons = fail
  2. Accuracy: sniping and head-shots requires keeping still, keeping fatigue at a minimum (no jumping for a while!)
  3. Positioning: is it better to circle round behind an enemy and catch them unawares (lots of jumping, weak weapons) … or go straight at them, guns blazing, and try to scare them into running while tired (they fall to their death)?


I like this idea because:

  • …who doesn’t want to play in The Matrix?
  • …”Canabalt … with guns”
  • …most FPS’s give you infinite mass and infinite acceleration … this one makes things a lot more realistic and interesting
  • …level-design will be easy! (procedurally generating skyscraper-roofs = WIN)

Make an FPS in 7 Days – Game idea: “Follow”

Next week is the 7DFPS challenge – design, code, ship a game in 7 Days, on the theme of “first person shooter”. I want to do something unique and interesting. Here’s one of my ideas.

(if you like this idea, please re-tweet this to vote for it – I’ll decide which to do based on which one(s) people like most) Other ideas: “Runners”, “Metamorphosis”)

Title: “Follow”

Premise: what makes an FPS unique/special among games is the visceral, immersive nature. Almost every *other* genre of game gives you 360-degree vision. This was originally to compensate for the way “a computer” fails to use most of your human “peripheral” senses (depth, perpheral vision, positional sound, etc). The most obvious difference with FPS’s: you can’t see what’s behind you.

In most FPS’s, you only have to worry about your own skin. You spin around frequently to check no-one is sneaking up on you. You strafe round corners so that a head-on enemy doesn’t get a chance to blindside you as you slowly rotate around the corner. Stealth games let you “lean” to make up for the danger of corners.

Core gameplay

Follow is different: you are invulnerable, and you’re being followed by creatures you’re trying to rescue / lead to safety. Because they’re always behind you, you cannot see when they’re being attacked – you can gun down all opposition, then turn round to find out everyone’s been eaten behind your back.

But if you walk backwards everywhere, you’re bound to fall off a cliff, or run into an enemy and only notice it when your followers go down in a hail of fire.

Challenges to the player

Moment to moment during the game, the player has to compromise between the following tensions:

  1. Avoid static obstacles/dangers (look where you run) … vs … prevent followers from wandering off (look behind you, at followers)
  2. Takedown enemies (charge forwards, run around obstacles) … vs … lead carefully (avoid leading your followers into traps / fields of fire)
  3. Hands-off (followers wander and get into danger) … vs … Hands-on (use non-lethal weapons to herd and cluster your followers, so you can keep them alive more easily)
  4. Get to level-end / safety quickly (lose lots of followers) … vs … slow, stealthy “no man left behind” (slower and painstaking but higher success rate)


Three interwoven upgrade paths:

  1. Player: might/damage/speed
  2. Relationship with followers: trust/obedience
  3. Followers: speed/intelligence/resilience

At end of each level, you get cash in a virtual currency based on how many followers you rescued, how quickly – and how much they like you.

(if you got them to the end by bullying … they won’t like you so much as if you gently nudged throughout)

Weapon availability

Potentially: various unique weapons only “unlocked” when you achieve difficult non-shooting things, e.g.:

  1. Complete a level with 100% survival of followers
  2. Keep followers at 90% or above happinness for 5 levels in a row
  3. Complete a level in under 50% of the “par” time

Ideally, those weapons would be complementary to the achievement. e.g. for the “complete a level fast” award, you’d get something that made it easier to complete levels stealthily (you’ve already mastered “moving fast”, so this gives you something valuable).

…also: if you don’t like playing fast, this gives you a high cost/reward incentive to do so: you want to play stealthily, you want the uber-weapon for stealth … so you need to take a break from stealth-play to go earn it.


I like this idea because:

  • …it’s an FPS about protecting people, rather than slaughtering them
  • …it emphasizes the vulnerability of “people other than myself”
  • …it demonstrates that making yourself into a super-soldier may be ultimately useless and unrewarding
  • …it makes the purely-tactical parts of an FPS a lot more strategic, as core gameplay – rather than relying upon “map design” and/or “multiplayer team tactics” to provide all the strategy

Preview of a new game: “Peace by other means” – Screenshots1

I’ve just posted some screenshots + notes for Reddit’s Screenshot Saturday, for the iPad game I’ve been working on for almost 2 years now.


Doesn’t look like much given how long it’s been in development :(, but I’m hoping it’ll speed up from here!

[homepage for the game]

Along the way, I’ve:

  • built the game
  • taught myself advanced Quartz / CoreAnimation
  • wrote a detailed playable game with AI
  • discovered the hard way that Apple doesn’t use hardware-acceleration properly on iPhone/iPad
  • threw away the 2D renderer, re-designed the game around OpenGL + 3D
  • re-wrote everything in 3D with OpenGL 1.x
  • taught myself OpenGLES 2.0
  • re-wrote everything with shaders

GamesThatTeach: “Let’s Play: Ancient Greek Geometry”

Excellent game for practicing circle/line/compass/ruler construction (as loved by junior-school maths exam writers): The regular polygons have been kidnapped by ninjas. Are you a bad enough dude/tte to construct the regular polygons with nothing but a virtual compass and straightedge?

“It’s a Compass and Straightedge tool/puzzle game written in JavaScript. I’ve always thought Geometric Construction felt like a puzzle, so to me this pairing was quite natural. Compass and Straight edge is a technique for constructing shapes out of circles, straight lines, and their intersection points. You can read the wikipedia here – but watch out, some of the gifs are spoilers for the game.” –

The exciting thing here is that it shows how to create “perfect” polygons – not estimated, not relying on a pre-made protractor / angle measurer, but 100% accurate, using rules of geometrical construction. For instance, here’s how to draw a perfect pentagon, without any tools beyond the compass/pencil/straight edge:

Firefox won’t save/open PDF files any more

What is it with Firefox’s developers these days? Every other release of Firefox seems to overwrite at least one existing setting … with a broken feature.

Firefox version 22.0 disables your PDF viewer and replaces it with a non-working proprietary viewer from Mozilla

Cure is quick:

Note: this works because “always ask” is less annoying than it sounds. It merely means “let me open it or save it”, and it will use whichever viewer you last used. On OS X that – out of the box! – means the system PDF viewer. Which works perfectly on everything except bizarro-interactive-secure-encrypted Adobe docs/em>

Continue reading

Anatomy of a cluster-f*ck: Imagination’s SDK installer

iOS devices (iPhone, iPod Touch, iPad) are powered by 3D chips branded “PowerVR” from a company branded as “Imagination”.

If you want to develop 3D games/apps, you can do that using Apple’s free tools + SDK. But some of the good stuff – e.g. higher-res textures – you’ll need to dive into PowerVR specifics. This should *in theory* be very, very, very easy. But Imagination does not make it so :(.

All you really need is a few source files, but instead of putting them on their website to for you to download, Imagination has wrapped them up in a 1 gigabyte (broken) self-extractor. And it doesn’t work. It *really* doesn’t work. Read on for some of the joys of just how awful something as simple as a “unzip this file” program can get…

UPDATE: I realised after posting that I left out a very important point. Until this mess, I’d found Imagination’s tech guys to be friendly and helpful, and their tools to be useful and to work fine. They were always badly documented (e.g. very bad error handling, missing key facts like “a 64 megabyte texture requires 3 GIGABYTES of RAM to save”, etc – but they essentially “worked”). Maybe I just got lucky until now, but this installer seems a radical departure in terms of quality and testing. For anyone who’s *not* used the PowerVR stuff before, bear this in mind: IME, this experience is not normal. Also: use the forums – the support team seems pretty responsive.

TL;DR – if you want to load PVR textures on iOS, google for “PVR” and “iOS” and “copyright imagination” and find the header files and source that are embedded in a couple of open-source projects from a couple years back, before Imagination accidentally broke everything.
Continue reading

WordPress: inline “signup email” drop into post or sidebar

My blog posts are info-rich and spam-poor. Most of the “enter your email address” plugins are designed for spam – covered in bling, in-your-face animations, background music, all sorts of crap.

There’s nothing out there, so I made one, using a GPL’d existing project. Feel free to use this yourself.

note: this is an image, not a form!
Screen Shot 2013-06-13 at 13.48.14

Continue reading

Games that teach: Code Combat = Tower Defence clone where instead of just placing towers … you write basic commands in javascript to manipulate your troops around the map:

This is an early preview build, so it ONLY WORKS WITH CHROME (EDIT: (deleted off topic personal commentary) … Chrome’s native plugin stuff is great, I can see why a lot of devs use it for prototyping … but the politics around Google, and their actions to edge-out more inclusive, free, open browsers is distressing)

Screen Shot 2013-06-10 at 19.36.04

SVGKit 2013 – Recipes (part 2)

(see also the first set of SVGKit recipes)

Change the color of a SVG element like a Path or Circle after the user click on it

CALayer* layerUserClickedOn = ...

if( [layerUserClickedOn isKindOfClass:[CAShapeLayer class]] ) // should ALWAYS be true, but just in case you write your code wrong...
   CAShapeLayer* shapeLayer = (CAShapeLayer*) layerUserClickedOn;
   shapeLayer.fillColor = [UIColor redColor].CGColor;

Find the CALayer that was generated from a particular SVGElement

NB: Apple/ObjectiveC uses “id” as a keyword, so we had to rename the SVG name “id” to “identifier”.

If your SVG file is legal, and has a unique “id” attribute for every SVGElement, then you can find the CALayer directly from the SVGElement, using the “id” attribute. If your SVG file has no “id” attributes, or the SVGElement you’re searching has no “id” element, then you’ll have to do more work – or fix the SVG file (edit it, add an “id” attribute to the SVGElement that matters, save it … then use this recipe)!

SVGKImage* svgImage = ...
SVGElement* element = ... // see previous SVGKit recipes
CALayer* layer = [svgImage layerWithIdentifier:element.identifier];
... // do something with it...

Clone part of the image, and move it around / change it

First of all, find the part of the SVG you want to clone, e.g. using “Search an SVG file for particular tags / nodes / elements” from the first set of SVGKit recipes.

That gives you an (SVGElement*). Use the previous recipe to get the CALayer. Finally, clone it and use it:

#import "CALayer+RecursiveClone.h" // requires SVGKit version 1.1.0 or later

-(void) someMethod
   SVGKImage* svgImage = ...
   SVGElement* elementToClone = ... // see previous SVGKit recipes
   CALayer* layerToClone = ... // see recipe above

   CALayer* newLayer = [layerToClone cloneRecursively];
   newLayer.frame = layerToClone.bounds; // reset it to be positioned at (0,0)
   // if you want the clone to start in same position as original
   // add this code
   if( calculatePositionOfOriginalLayer )
      CGFloat xOffsetOriginal = 0.0f;
      CGFloat yOffsetOriginal = 0.0f;
      CALayer* parentLayer = layerToClone;
      while( nil != (parentLayer = parentLayer.superlayer) )
         xOffsetOriginal += parentLayer.frame.origin.x;
         yOffsetOriginal += parentLayer.frame.origin.y;
      CGPoint positionOfOriginalLayer = CGPointApplyTransform( layerToClone.position, CGAffineMakeTranslation( xOffsetOriginal, yOffsetOriginal ) );

Edit the polygons / lines / shapes after loading

Every “shape” is stored as some form of Apple CGPath object.

CALayer* layerInSVG = ... // use a previous recipe to get the layer from the SVG element
CAShapeLayer* shapeLayer = (CAShapeLayer*) layerInSVG; // if you chose wrong, this will error at runtime
CGPath pathToEdit = shapeLayer.path;

... // edit the path, and create a replacement path

shapeLayer.path = myEditedPath;

Apple doesn’t provide an API to directly edit CGPath objects. They have a C API that let’s you create a callback function that turns the CGPath into a list of draw-calls, that you can then work with. But it takes quite a bit of code to read this, and then convert it back into a CGPath that Apple can draw.

So far, no-one has open-sourced their code for this (I’ve got a private version I wrote for a previous project, but it’s thousands of lines of code). Either petition Apple to add the missing APIs, or find someone to write it for you / license it to you, or write it yourself.

Designing Bomberman with an Entity System: Which Components?

Today I found a new article on implementing a Bomberman clone using an Entity System (in C#) – but I feel it doesn’t quite work.

It’s a well-written article, with some great illustrations. But the authors “Components” struck me as over-complicated and too behaviour-focussed. If you’re designing a game based on an ES, this isn’t a great way to do it – it feels too much towards old-style OOP gameobjects.

This is an opportunity to talk about good and bad directions in Component design. I really like the author’s idea of using Bomberman as a reference – it’s simple, it’s a well-known game, but it’s got a lot of depth. Read the original article to refresh your memory on Bomberman and how it works. Then come back here, and we’ll do a worked example on choosing components for a game. I’ll completely ignore the programming issues, and only look at the design issues.

Continue reading