Tuesday 2 March 2010

2 Mar 2010 - A problem with the Natives

Another issue, another solution. Once again the programmers on the UDK forums have pointed me in the right direction and have helped me stop the game crashing on startup, which, as errors go, is a bit of a big one.

Apparently the critical error was cased by my vehicle script (no surprises there) - as it borrows heavily from the default 'Scorpion' vehicle that comes with the game. The error in the game's log file (found in 'UTGame\Logs') was this:

Critical: Can't bind to native class *name of custom vehicle*

This was caused by the 'borrowing' of the Scorpion's code. The Scorpion has a 'native' class definition in it's script, which can only be used by official vehicles that come with the development kit (I assume this also applies to other objects that Epic provide with the UDK).

So, the solution is to remove any references of 'native' from the vehicle script. In my case, it was in the UTVehicleMaxtonSteamCar.uc file. I commented out the code using /** and */ .



This wasn't successful initially, resulting in the exact same crashing on startup. But another look at the UDK's log files showed two more messages:

Error, Cannot use cpptext blocks in non-native classes

Error, Only functions of native classes can be declared native

This required a further study of the script but was solved quickly thanks to the search function. It just required further commenting out of the 'cpptext' function and another 'native' reference further down the script:


Running the game seems successful now, and it loads up without crashing! Of course, commenting out code rather than deleting it allows me to return to the default script if anything should go horribly wrong - but so far, so good.

I cannot describe how important looking at the log files are. Not only do they give you an error to work with when looking for a solution, but they also give you the file in which the problem lies, and the line of code that is causing the issue. This saves such a lot of time!