Crash with "waterreflection.as" script

Hello, i’ve found a script for waterreflection here : Water reflection script , is work fine
with some modification ( like fov ) with the editor.

But, when i load the scene with native c++, my application crash with any error message , if i comment
the line 35 & 36: “Viewport@ rttViewport = Viewport(renderer.viewports[0].scene, reflectionCamera);” , the program run without any error and i dont see any reflection…

i have created in c++ an empty scene, after i loading scene and i grabing camera from previously loaded scene for create viewport. and i don’t known why that dont work.

can anyone help me ?
thanks. and sorry for my bad english.

Please make sure you check the pointers, is viewports[0] valid?
Posting the callstack of the crash would help a lot too.

Ok, i’m beginner with AngelScript, how can view the callstack ?
“renderer.viewports[0].scene” is not provided by the current scene and the curent viewport ?

I’m not sure about AngelScript, I’d just check its console output.
You said you can reproduce the crash in C++ too, so you can put a breakpoint on the culprit line of code and see what’s going wrong.

Without looking at your code it’s difficult to tell where the problem is, the only suggestions I can give you with the information I have are these.

You could also try checking the pointer in AngelScript as:

Viewport@ view = renderer.viewports[0]; if(view is null) Print("Viewport is not there!");
Note: the above can be used to check any pointer. For example, the renderer or the camera, just use and adapt to the correct data types.

In C++ would be way simpler though.
If you did not already, I strongly suggest you to learn how to use GDB or VisualStudio debugger, as they literally save you a lot of time and troubles.