Sunday, February 10, 2013

Some progress on the book

After a week a furious reading, I finally reached chapter 7 of the book. On the way, I learned a good amount of things.

The first of these things is lots of syntax for  inheritance relationships:

Class CustomActor extends Actor;
self.EatAPancake();
super.ClimbMountEverest();
who refer respectively to declaring an inheritance relationship, getting the reference to the instance calling the code, or calling the superclass' implementation of a function. No big surprises there.

There is also lots of specific syntax for variables themselves:
  • local is used for declaring temporary variables while inside a function; note that you can only declare local variables at the beginning of the function, like in C.
  • config which I previously talked about;
  • const which is for constant variables, unsurprisingly and like many other languages out there

A LOT of specific syntax for functions:
  • event for events (mostly, just functions called from the native C++ code);
  • simulated, client, server, reliable, unreliable are all modifiers that are used for multiplayer functions;
  • const, NoExport, latent, iterator for people who can use native C++ code with the engine (i.e. people who pay for the license. Other people can use the ones already created, but not declare new ones). Out of these, latent means a function only usable while in a state, and iterator is for subroutines.
  • native is pretty straightforward, and obviously subject to the same limitations as before;
  • singular to prevent the function from being recursively called and thus prevent potential crashes from infinite recursion;
  • exec which is for functions that can be called from the console and for player input functions.
There might be more. I'm pretty sure I saw some final (non reeimplementable, I assume) and coerce (??? remember to check the doc for this one) laying around.

Also, there's a pretty cool implementation of states: by using the state keyword inside a function, one can define a set of functions usable only by this state. The state changing is as simple as calling GoToState('StateName'); and there are some useful BeginState and EndState functions. Of course, redefining a Tick function there is the obvious thing to do (it's the update function, same as Update in Unity). Having previously implemented a state machine in C# for the Barreleye project, I'm more than glad this is already there. Oh, and they can be "subclassed" :)

And finally, learning about Kismets has been pretty fun. Kismets are a sequence of events that can be created in the editor itself; it's visual programming for designers. With patience, one could probably write a game entirely in kismets; however, it would get complicated really fast, in addition to the kismets being run on a layer on top of UnrealScript which makes them slower. Also, kismets are valid only for the level they're created on.

Since Kismets only became clear after actually working with them, here's an image of a kismet I made with the book's help (note that it also includes a kismet created from UnrealScript code :)):

There. Only 3.5 chapters to go!

No comments:

Post a Comment