Sunday, December 30, 2012

Faking an AS3.0 document class in AS2.0

Depending on which VM you want to use, some people are still forced to use AS 2.0 for Scaleform development. if so here's scope can be a total nightmare, so why not start off your classes in a nice orderly fashion by faking an AS 3.0 document class.

BIT-101 - Document Class in AS2

Amazing list of tutorials from Tegleg

Tegleg is amazing on the forums ans here's a pretty stunning list of tutorials and bits n pieces

How about this for an exremely comprehensive list of programming resources

I found this list of resources from From Amit Patel over at WillyG's blog. 

My latest quest is to wrap my head around ussing Visual Studio with UDK and try and get nFringe working as not having intelisense in Flash Develop is just driving me insane.


EDIT: Found this in my drafts, thought the links alone were worth publishing this post.

Unreal script and intelisense

The one thing that has driven me insane trying to work with Unreal script hasn't been the syntax, nor the way the script is layered on top an invisible laye of C++ commands running all the time. It's the fact I'm still not comfortable writing code from scratch.

Everything I'm doing is copy and pasted and that's mainly down to not having the features I'm spoilt by having in Actionscript using FlashDevlop.

I've managed to hack my way through to having some sort of syntax colouring but it's just not enough, I need intelisense, I need 'Go to definition' and that's why I've decided to give Unrea Script IDE a shot, it's layered on top of Visual Studio, which as nasty and bloated as I remember it, is the real deal in terms of game development.

One thing I must mention is that not following the installation instructions can, as always, bite you on the arse.
RTM.


Saturday, April 14, 2012

How to get UnrealScript Syntax in FlashDevelop


I've copied the as2.xml and used the syntax highlighting xml I grabbed from from a link on the UDK forums

UnrealScript.xml save it here:

C:\Users\<USERNAME>\AppData\Local\FlashDevelop\Settings\Languages\UnrealScript.xml


Then Edit the C:\Program Files\FlashDevelop\Settings\MainMenu.xml

Add this:
<button label="&amp;UnrealScript" click="ChangeSyntax" tag="UnrealScript" flags="Enable:IsEditable+Check:IsEditable|IsActiveSyntax" />

Underneath:
<button label="Label.Text" click="ChangeSyntax" tag="text" flags="Enable:IsEditable+Check:IsEditable|IsActiveSyntax" />


Then in  C:\Program Files\FlashDevelop\Settings\ScintillaNET.xml

Add:
<include file="$(BaseDir)\Settings\Languages\UnrealScript.xml" />

This should now give you and option to use 'UnrealScript' in the syntax dropdown.

I've created an empty Haxe project and saved it inside C:\UDK\UDK-2012-02


One of the main features I can't stand in visual studio and notepad++ is having to maintain my project file, in FlashDevelop the project shows what's actually on disk and for me that's a huge time saver.

In my opinion Flashdevelop is simply the best code editing tool I've used. It's customisable, simple, and easy to use. features like duplicate line, wrapping searches and project /outline panels are worth their weight in gold when it comes to spending less time fighting your IDE and more time coding.


Friday, April 13, 2012

Magically disappearing assets in UDK

Last weekend I started adding my kids pictures into a UDK as we have plans to make a simple game, collecting items and battling trolls usual sort of stuff. I downloaded the latest beta for Adobe Photoshop 6 draw a path around each character, made it into an alpha channel and saved it out as a tga 32bit to keep the alpha.

I've not really played with alphas and transparencies in UDK but my idea was to create a simple plane, stick the texture onto the plane and that'll do me. Although it was a bit more trial and error than i had imagined I finally got there (see pic)

For the texture I used compression for TC_OnBitAlpha and for the material I plugged rgb into diffuse, alpha into Opacity then set the Material / Blend Mode to BLEND_Alpha_Composite. This seemed to work fine until I noticed the translucency in the sea material was cutting through the 'prince' material, so back into the material for a bit more tinkering and Misc / Enable Separate Translucency seemed to do the trick.

So, everything seemed to be going well, I imported a couple more textures, created materials and left it for lunch. When I came back I reopened my UDK level to find all the newer textures had gone.  

I tried and retried and managed to replicate it every time, I even imported static meshes but everytime I closed and reopened my level they were gone.

Being the dog with a bone type, I added a new level saved it various places, I eventually reinstalled Feb edition and then March just to be sure and every single time I got the same results.

I took it to the forum and checked everything anyone suggested to be sure, then I realised it had something to do with saving the current level verses saving the package.

I separated my textures and materials into their own package and it saved and reopened fine. Pretty much just as I did JetFire left me this gem

"Looks like if I import a texture and don't use it, it gets lost? < this, if you're embedding assets into your level file, rather than a separate .upk- If not used in the scene they'll get wiped. So, either use them, or put your stuff into separate upk's which don't have this feature."
So there you go, use or you lose.

I'm going to have a textures_materials package from now on.

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

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

Wednesday, February 22, 2012

People getting it right

I can't even remember how I stumbled upon the writings of WillyG but I'm very glad I did. His battles with saving game content and highlighting of the subsequent release of the UDN BasicSaveObject and Daniel H's tutorial both of which are worth a read if you want to get to grips with saving anything in your UDK game.

Hi

What better way to keep track of what I've been up to than writing in down.

Currently I'm playing with UDK (again) and it's the again bit that means I'm having to relearn what has been forgotten since the last time I played with it. Hopefully keeping a running blog of general stuff will help out after the next slump / cod title.