Computer programming

You are here

On Clarity and Beauty

I noted today how much I like programming - especially when I can try out new stuff. Not necessarily thematically new stuff (it’s not like I haven’t programmed a score manager before), but when I can do it in a stylistically new way. In this case, I tried to do it using dependency injection, something I stumbled over while trying to learn Angular.js – and then subsequently on the Unity blog.

Yes, I will absolutely obsess over these things.

English

AI-Driven Dynamic Dialogue, the Valve Way

Yet another trouvaille thanks to Robert Yang:

Valve’s Elan Ruskin’s GDC talk about AI-driven dynamic dialogue, used, for example, in Left4Dead.

English

Clean-Up Day: New Tricks with C#

Since I’m currently cleaning up my code to hand it in with my project, I figured I could write some of the stuff down I learned during my work on our game.

All of it applies, of course, to C#, and was used in Unity 3D.

Checking for a type

Using the is keyword, you can easily check whether a certain object is of a desired type. Also, you should be aware of the as keyword, that allows you to cast an object as something else (given that this is possible).

English

Random Object Placer for Procedural Design

Another script that is the result of the ProXedural project at the ZHdK. It produces a somewhat randomly generated level of the size of a collider that is placed over a terrain in Unity 3D.

By using a somewhat mixed approach of completely random raycast placing and placing objects using an array, the script can ensure that the different kinds of objects are distributed all over the terrain.

Again, the script may be oddly specific at times, so you might have to adapt it to your needs if you intend to reuse it.

English

AI Walker Script

A simple walker script for Unity 3D in C# that tries to avoid obstacles. It has been used in the ProXedural project at art school, and it made the cows walk towards one of the players. To be honest, it does not really deserve the I in AI. But then again, no one expects cows to be very clever.

Maybe someone can use it as a base to produce something better (oh well, who am I kidding, this has already been done).

using UnityEngine; using System.Collections;

English

Programming Finite State Machines in Unity3D using C#

Finite State Machines are quite a convenient design pattern in Game Design, as they allow for quite some flexibility when programming AI behaviour.

English

Getting Things In and Out of Arrays in ActionScript or JavaScript

Since I have a hard time keeping push(), pop(), shift() and unshift() apart, here’s a little cheat sheet I whipped up:

Array Manipulating Cheat Sheet

Undefined

Dynamically Referencing Variables and Methods in ActionScript

Sometimes, the state of an object decides which method has to be executed. Instead of an unwieldy switch construction like this …

switch (task) {

case "sleep":
sleep();
break;

case "walk":
walk();
break;

}

… you can use the someObject[someExpression] notation. This works for any object, and you can use it to access both variables and methods. All those lines from above become this:

thistask;

English