Wednesday, March 28, 2012

Not so mental notes on GFxMoviePlayer, GFxObject and GFxValue

I do make mental notes, lots of them, it's just that some don't seem to stick as well as others.

NB this is from UDK 02/2012


GFxMoviePlayer which extends Object (the base class for everything in UDK) is pretty much the viewport and is permitted only one gfx movie which is set in it's MovieInfo variable, this all makes perfect sense now.

GFxObject also extends from Object, but this time it's constructor uses the 'within' term, which I can only guess (for now as I have no idea) that within the context of there actually being a GFxMoviePlayer and therefore a GFxMovie that a GFxObject can exist.

class GFxObject extends Object within GFxMoviePlayer

dependsOn(GFxMoviePlayer)


It's also worth noting that in the comments above this constructor, someone just as confused by all this, took it upon themselves to straighten things out with this gem:

/*
GFxObject is GFxValue in Scaleform code
*/


GFxValue the fundamental datatype in scaleform code for a MovieClip, now that I can understand

Saturday, March 24, 2012

Getting UDK under control part 2

If you are carrying on from part 1 then you should be able to navigate into your new project. If you click on the code button the under code click HTTP you should see something like this:














  • Copy the contents of HTTP access and paste them into NotePad (or something similar) 

svn checkout --username=cheesewhiskg https://svn.code.sf.net/p/mycustomudkgame/code/trunk mycustomudkgame-code

This is the entire command to get the code from your repository but as we're going to be using tortoiseSvn we only need this bit:

https://svn.code.sf.net/p/mycustomudkgame/code/trunk

  • Remove the everything else so your URL starts with https and ends with trunk.

We need to set up a folder to link to our repository, lets set up something on the desktop for now to get us started.
  • Go to your UDk directory C:\UDK\UDK-2012-02
  • In the folder and right click anywhere then down to 'SVN checkout... '
  • Paste the URL you edited in NotePad into the 'URL of repository' and click OK
  • You should be asked for your login credentials and save them *
  • TortoiseSvn will grab everything from the repository and download it to your folder. 

But wait, there's nothing in our repository right? Wrong, svn uses invisible metadata folders to keep track of all your files, what we've just done is set up a link between out repository and this folder. 

Try right clicking in the folder again, notice how 'SVN Checkout...' has been replaced with 'SVN Update' and 'SVN Commit...' 

Also if you close the folder you will see a nice big green tick overlaying the folder, this means that everything inside this folder is up to date with the repository on the server.

So this is great, but what we want to do next is actually add something to our repository right? 

OK so, add a new folder perhaps call it something like 'Assets' where artists can save their .max files before importing them into the UDK package.
You should notice that the icon overlay is blue with a question mark, this is SVN for WTF, it has no idea what this folder is because it doesn't exists in the repository.
We tell it all about the folder by Right clicking on 'Assets' and going to 'TortoiseSVN>Add...'
You should get a panel showing which files you are about to add, click OK

If everything went well you should now have a panel with 'Add Finished!' at the top, again click OK
The icon overlay on 'Assets' should have also changed to reflect this, it should now be a blue + symbol. 
If we come out of the parent folder you will notice it's overlay icon has also changed, but now it's a red ! symbol, this means we're out of sync with the repository, but didn't we just add the file? Well yes but we now need to commit that change.

  • Right click on 'Assets' 
  • Go to 'SVN Commit...'
  • You need to add a message to every Commit you make, this should be something descriptive about what you are changing.
  • Type something like: 'Adding initial art assets folder' and click OK
If everything went to plan Assets will have been uploaded and all our icons will have nice green ticks. w00t!

We've come a long way, but we still haven't added our project, in part 3 I'll be explaining which folders we want to get under control because we don't want to have to upload 7+gb now do we.




* You can only store one pair of auth credentials in tortoiseSVN at any one time, if you move between projects you need to clear them by:
  • Right clicking anywhere go to tortoiseSVN>Settings
  • Click Saved Data
  • Next to where it says 'Authentication data' click 'Clear'

Getting UDK under control part 1

Setting up our environment


If you are going to work on anything of any value in UDK then it's definitely worth keeping a backup of it. But what if you make some changes that break your game? Usually big game breaking changes are difficult to debug at the best of times and ideally you want to keep a working copy for you to refer back to and this is where version control steps in. In this case I'm going to use the industry standard subversion more commonly known as svn.

Subversion essentially allows you to store incremental versions of your work on a server, when you make a change you are happy with you commit it to your project folder on the server called the repository.

Another great use for svn is that multiple people can commit work to the same repository which means you can all work on the same project at the same time.

Download subversion package here install and restart your machine.

You can use svn via the command line, but that's a bit too restrictive for me, I prefer to use Tortoise SVN which gives me context menu when I right click files and folders to perform svn actions such as commit.

Download and install Tortoise Svn too

So now what? Well we now need somewhere to put our UDK game files and for this I've chosen SourceForge although you could host your own svn repository if you have one set up, but SourceForge  is again free which is perfect.

Register yourself and account, you'll get a verification email once you've done that which will allow you to log in and set up your project.

This should take you into your account page, from here click 'projects' then 'register a new project' on this page you can add your project name, I'm going with 'MyCustomUDKGame'

Make sure you tick SVN and untick GIT the main reason for unticking GIT is that the code icons are identical and it becomes a bit of a pain having to figure them out later on.

Whatever else you tick or untick is up to your personal preference.

So now we have all of our tools and our hosted project set up on SourceForge, in part 2 we'll actually be adding our game code and assets into the subversion repository.

Where to put your UDK content

So when you first get started a lot of tutorials tell you to add tot he main Content folder within the ie they tell you to save your first map in C:\UDK\UDK-2011-09\UDKGame\Content\Maps

For me this is way too messy and organised, what I didn't appreciate at first, is that you can save anything anywhere as long as you point to the right folder in your code. So with this being the case I can be as anally retentive as my OCD for organised file structure requires.

With Maps being a bit old school, I've opted to follow the UT3 structure

C:\UDK\UDK-2011-09\UDKGame\Content\MyCustomGame\Environments
C:\UDK\UDK-2011-09\UDKGame\Content\MyCustomGame\Characters
C:\UDK\UDK-2011-09\UDKGame\Content\MyCustomGame\Vehicles
C:\UDK\UDK-2011-09\UDKGame\Content\MyCustomGame\Weapons
C:\UDK\UDK-2011-09\UDKGame\Content\MyCustomGame\UI

So as you can see it's all under the main folder which for me makes sense if it's the game they are all for 'MyCustomGame'

The beauty of this is that if I want to update to a newer version of UDK or put my files under version control, it's far simpler to have it under one directory than spread out across the many subfolders of UDK.

How to write a bat file

The basics are simple, you essentially open Notepad type in whatever command you want to call and save it with a .bat extension.


Anything written in the bat file will be called as a command line argument eg 


dir c:\windows

ECHO outputs to the console window and is the equivalent to trace in actionscript or puts in ruby
Having an @ symbol stops anything after it from appearing in the console window
So what does all this mean, well it means the first line of code we will want to turn ECHO off and also not show that line with:

@ECHO off 
dir c:\windows 

Save this as run.bat and double click it to run it. You will see it's gone in the blink of an eye, what we need is it to hang on a second so we can read it and for that we need to add a PAUSE.

@ECHO off 
dir c:\windows
PAUSE

Now when we run the bat file we see all the contents of the c:\windows directory listed out for us.

Another useful command when you are first playing with this stuff is REM, REM comments out a line of code but it will still appear unless you turn ECHO off.

There's tons of useful info here

Wednesday, March 21, 2012

How to add your custom gametype to UDK

The amount of times I've done this and forgotten isn't even funny anymore.
Edit this file:

C:\UDK\UDK-2011-09\UDKGame\Config\DefaultEngine.ini


[Engine.ScriptPackages]
+NonNativePackages=UTGame
+NonNativePackages=UTGameContent
+NonNativePackages=CustomGameTypePackage
...
[UnrealEd.EditorEngine]
+EditPackages=UTGame
+EditPackages=UTGameContent
+EditPackages=CustomGameTypePackage

So now the engine will look for code inside your new package:

C:\UDK\UDK-2011-09\Development\Src\CustomGameTypePackage\Classes

From here you need to create you own Class and to get up and running quickly extend a game type you should know about, UTDeathmatch


Save this code in a file called MyCustomGame.uc


class MyCustomGame extends UTDeathmatch;


defaultproperties
{
}




Once you are in the UDK editor you can set the map to whichever gametype you want using world properties. Remembering that the map is the world and multiple games can occur in that world.

View>World Properties>MyCustomGame

Default Game Type
AND
Game Type for PIE

Set both dropdowns to your gametype 'MyCustomGame'



How to change UDK intro video


Download the The RAD Video Tools and export whatever video you want to appear at the front of the game

Save the movie as 'UE3_logo.bik' into here remember to change the version numner if you are not using september 11 edition, which you are probably not.

C:\UDK\UDK-2011-09\UDKGame\Movies


Scaleform over bink movie

I spotted a forum post about scaleform movie over a bink movie and wondered how easy it was to add a bink movie to UDK, it turns out it's fairly easy.

As always Lexluthernumber1 has a video on how to use bink movies in UDK on his youtube channel so carrying on from Matt Doyle s tutorial I added a bsp brush and it worked just fine.

Basically:

  • Download the The RAD Video Tools and use it to compress your video as a bink movie
  • Import the bink movie into your package and save it
  • Right click the movie and choose 'Create new material'
  • Connect the texture to the diffuse channel and save the material
  • Next select the face of the bsp you want to movie to be on and apply the material
  • Adjust to fit and test in game
As you can see I have two very quick bsp brushes, the one in front is 'some squares' I added and the one behind is the bink video. Obviously you would need to make a bit more effort but here I'm just seeing what's possible.





Sunday, March 18, 2012

Gfx in kismet

So it seems that any class that extends GFxMoviePlayer is available in kismet under 'Movie Player Class'

I was trying to add Matt Doyles code to basically see what the process for adding unrealscript to a gfx movie and discovered that you can give a gfxMovie in kismet, a player class, in this case a I used his code but added my own classname 'CWHudNew' and extended GFxMoviePlayer, remembering to move his properties to the correct defaultproperties section and pointing to my own .swf inside the class.



Getting flash files into UDK

So first off I grabbed a trial for Flash CS5 and my favourite Actionscript editor FlashDevelop, grabbing java RE along the way.

Matt Doyle has an 11 part intro into using scaleform in UDK over at scaleformpress which is pretty good at giving an overview, but the UDN site is still the best place for up to date info on scaleform in UDK. 

If you read through the getting started there's a few things I want to point out:

First of is that all .swf files must be published into the Flash folder
C:\UDK\UDK-2011-09\UDKGame\Flash
Yes, I'm still running September because I'm still happy with it, I'll probably move to the latest version so I can play with GfX 4.x soon enough.

So, this is where all swf files have to live in order to import them into UDK, which is probably to do with the fact that the gfxexporter (C:\UDK\UDK-2011-09\Binaries\GFx\gfxexport.exe) uses an absolute path as it runs when you import an swf into UDK (guessing here). This brings my onto my next point; you can create your own subfolder within 'Flash' and this will be used as the package name for all your imported flash / scaleform content ie I chose
C:\UDK\UDK-2011-09\UDKGame\Flash\CWHud and the import process automatically created a package 'CWHud' for me.

One of the nice things in UDK is that you can save you packages wherever you like, so now I can create a nice tidy UI folder in my content folder:

C:\UDK\UDK-2011-09\UDKGame\Content\Cheesewhisk\Content\UI\CWHud.upk






Sunday, March 11, 2012