I have an application written entirely in script, in it you’ld have to shoot down some drone like objects. The Node for the Drone has a ScriptObject implementation named DroneObject created into it while that of the bullet has BulletObject created into it.
Below is the node collision handling routines of the BulletObject script object
void HandleNodeCollision(StringHash eventType, VariantMap& eventData)
{
Node@ otherNode = eventData["OtherNode"].GetPtr();
DroneObject@ droneObj = cast<DroneObject>(otherNode.scriptObject);
if(droneObj !is null)
{
droneObj.OnHit();
}
Destroy();
}
Everything works well. But when I try to implement this same application in c++ I notice a strange issues.
Now just like the fully scripted application, the drone and the bullet nodes have their respective ScriptObject created into them. But the line below in the BulletObjects HandleNodeCollision
always returns a null pointer whether the node DroneObject script object or not. Even when I use another method to retrieve the script object, like
ScriptInstance@ sInst = cast<ScriptInstance>(otherNode.GetComponent("ScriptInstance"));
DroneObject@ droneObj = cast<DroneObject>(sInst.scriptObject);
i still get a null pointer. Every other thing works, but in the part were I have to retrieve a scriptObject from a node null is returned, no error is thrown and the application log shows no error either. What am I doing wrong or is it a bug coz its still the same ScriptObject files I use for both the fully scripted app and the C++ app