🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Calling method from script class - Null pointer exception

Started by
2 comments, last by veridis_quo_t 3 years, 8 months ago

I'm trying to call a method on a script class from C++, but I keep getting a null pointer exception, I've been stuck on this for about a week now… I'm using an almost exact copy of the example in the documentation. What is weird is that it calls the function successfully, but then crashes immediately after…

Here is a minimal reproducible example (C++ 11): https://pastebin.com/EraySHgz

None

Advertisement

In your code you're attempting to call the script function twice. The first time you're doing it correctly. The second time you prepare the context, but don't set the object before calling Execute, which is the reason for the null pointer exception.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Oh ok… I was misunderstanding the way it works, I thought that the object got stored inside the context as some kind of userdata…

None

This topic is closed to new replies.

Advertisement