Monday 2 May 2011

Creating a custom actor part 1/4

Before we jump into coding our custom actor in UnrealScript, it would be good to know what we are trying to achieve. Actors are basically all gameplay and level elements that can be placed in a level. Think of static meshes, weapons, pickups, players etc. The image below presents the basic look of our custom actor that we will create.



So what do we have here? As you can see in the image, our actor consists of a mesh (standard UT pickup base), particle emitter and collision component (you can press C key in Unreal Editor to view collision). Later on you will find out that this actor also has a sound component, so that it can play sounds in the level.

In Unreal Engine there are of course more Actor components than that. You can learn more about Actor components at UDN. Actor components are basically modules that add certain functionality to the base Actor class. Instead of keeping all the code and functionality in one class, you can simply decide which components you want your specific actor to have.

Ok, so what exactly is this actor here? Well, I called it a HealthFountain.

Imagine a safe spot in your level, where the player can slow down for a moment, take a break from beating all the bad guys and regenerate their health. This is where the HealthFountain comes in. The player can simply enter the fountain and restore health points (unless your game uses automatically regenerating health and armour, then this is pretty much useless). Stepping out of the fountain will stop the regeneration process. Also if player’s health was restored to the maximum, the fountain will stop healing the player. The HealthFountain has a health points limit though and once the health points run out, the fountain will be empty and disabled. How do we know that the fountain is running out of health points? Well, the amount of particles will let us know. The fewer health points are left in the fountain, the fewer particles will be emitted.

I made an example video showing how this is going to work.




In the next post we will jump into coding our custom actor using UnrealScript.

No comments:

Post a Comment