Introduction to Unreal Script

  • Ways to add additional content to Game Engine:
    • Write code in the same language (native code) that the game engine was written in.
      • Advantages
        • Speed of execution.
        • Familiar development environment.
        • Easier path of integration with code.
      • Disadvantages:
        • The entire game or portion of the game would have to be recompiled which can be an extremely lengthy process.
        • With longer compile times, testing game content and making tweaks to behavior becomes a very time consuming.
    • Use a separate language from our game engine that is executed by the game engine itself.
      • Advantages:
        • Solves the problem of inflexibility of native code.
      • Disadvantages:
        • Comes at a heavy performance cost.
          • When code has to be interpreted by the game engine at runtime, the computer is not going to be able to do as much processing as a sophisticated game might need.
    • Use a mixture of the first two methods.
  • Unreal Engine has Virtual Machine!
  • Regardless of how we get the scripts running, the compiled scripts are executed by the Unreal Virtual Machine, which is just a name given to several components which all are involved in the running of the compiled scripts. These components include the server, the client, the rendering engine, and the engine support code. Together these components translate the bytecode contained within the compiled scripts into the result the player sees on screen during play.

    When to use Unreal Script

  • So, when is it best to use UnrealScript and when is it better to use native code? As a general rule, scripts should be designed to be idle the majority of the time. In essence, the code in an UnrealScript should only be run after the firing of some specific event. Take a health pickup, for example. This object will constantly be polling to see if something touches it. Then, once it finds a touching object, some specialized functionality will be applied to that object. It simply would not make sense for the polling to be done in UnrealScript as that would bog down the system and thus slow down the game. Instead, a special function, or event as the case may be, would be written in UnrealScript that would only handle the functionality that is to be performed on touching objects as they are found. This function would be called from the native code which would be handling the polling. This is a great example of how native code and UnrealScript can work together to make your game efficient.
  • This is not to say that there are not situations where scripts will need to perform some functionality every tick or every few ticks. In fact, there are several cases where this is absolutely necessary, especially if you are unable to write your own native code for your class. In these situations, the code inside of the Tick() function will need to be optimized as much as possible and only perform essential operations. In some cases, the code in the Tick() function may only need to be run every so often. Adding up the elapsed time each tick and only executing the code when that time reaches a specified amount is a good way to keep the system from slowing down.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s