Hi! I've been studying the NinjaSnowWar sample to learn how the engine should be used. I was building my own project with bits and pieces from the different samples when I stumbled upon a null pointer exception. I found that this error was from a snippet I got from NinjaSnowWar and I was wondering if this is a bug or if I'm using the engine incorrectly.
It works when I run it from it's default location:
niklas@Dash:/opt/Urho3D/Bin$ ./Urho3D Data/Scripts/NinjaSnowWar.as
But when I run it from my project folder (in which I've copied all the resources into):
niklas@Dash:~/Workspace/ugame$ /opt/Urho3D/Bin/Urho3D NinjaSnowWar.as
...I get the following errors repeated on every frame:
[Tue Oct 29 20:12:24 2013] ERROR: NinjaSnowWar.as:1015,17 - Exception 'Null pointer access' in 'void UpdateControls()'
AngelScript callstack:
NinjaSnowWar.as:void UpdateControls():1015,17
NinjaSnowWar.as:void HandleUpdate(StringHash, VariantMap&inout):408,5
[Tue Oct 29 20:12:24 2013] ERROR: NinjaSnowWar.as:1137,13 - Exception 'Null pointer access' in 'void UpdateStatus()'
AngelScript callstack:
NinjaSnowWar.as:void UpdateStatus():1137,13
NinjaSnowWar.as:void HandlePostUpdate():445,5
These are the code snippets causing this:
// void UpdateControls():1015,17
Node@ playerNode = gameScene.GetChild("Player", true);
if (playerNode !is null)
{
log.Write("prenode");
Ninja@ playerNinja = cast<Ninja>(playerNode.scriptObject);
playerNinja.controls = playerControls;
log.Write("postnode");
}
// void UpdateStatus():1137,13
GameObject@ object = cast<GameObject>(playerNode.scriptObject);
health = object.health;
There is absolutely no difference made to the files other than executing them in another directory relatively to the Urho3D executable. Is this an error caused by a misunderstanding of how the Urho3D script functionality works or is this an issue with Urho3D?
Thanks!