Null pointer excepotion in script

I started playing with AngelScript yesterday and of course, found my first problem:

[Tue Nov 25 07:49:46 2014] ERROR: Scripts/,2 - Exception 'Null pointer access' in 'void Start()' AngelScript callstack: Scripts/ Start():11,2

This is the main code:

[code]#include “Scripts/Engine/”

Scene@ gameScene;
IsoCamera@ cam;

void Start()
gameScene = Scene(“castle-gates”);
cam = IsoCamera(); <----- This is the error line

if (!engine.headless)
    renderer.viewports[0] = Viewport(gameScene, cam.gameCamera);


This is the camera creation code:

[code]class IsoCamera
target = Node();
camNode = target.CreateChild(“camnod”);
gameCamera = camNode.CreateComponent(“Camera”);
camNode.position = Vector3(0, 55, 52);

void SetPosition(Vector3 pos)
	target.position = pos;
Node@ target;
Node@ camNode;
Camera@ gameCamera;


Can somebody seee where is my mistake?

Since IsoCamera is a class defined in the script and so can be value assigned as well you need to put:

   @cam = IsoCamera();


Hmm, I tried removing @ from IsoCamera@ cam; and worked too. Is that correct too?

Yes. An @ symbol is a handle see: … andle.html.

Its only not needed for urho defined c++ (or custom defined c++ classes) that don’t support value assignment (using certain asBEH_ when defining the class in c++), any classes you declare in scripts and have a variable declaration using the handle will need to be assigned @varname = Var();. If you’re not passing the variable around lots no need to use a handle, if you are you’d probably prefer it, its a wierd mix of c++ reference and pointer.