Ok, so I think i fixed my issue.
Well, I worked around it.
I think that I am just not using scriptObject right, vs just a basic class. I am/was just confused on when to use them and what for specifically.
My Character class, that I am trying to call from my initial example, is as such:
class Character:ScriptObject{
RigidBody@ _body;
void set_parameters(){
StaticModel@ coneObject = node.CreateComponent("StaticModel");
coneObject.model = cache.GetResource("Model", "Models/Cone.mdl");
coneObject.material = cache.GetResource("Material", "Materials/StoneTiled.xml");
_body = node.CreateComponent("RigidBody");
_body.mass = 0.25f;
_body.friction = 0.75f;
_body.linearDamping = 0.6f;
_body.useGravity = false;
CollisionShape@ shape = node.CreateComponent("CollisionShape");
shape.SetBox(Vector3(1.0f, 1.0f, 1.0f));
}
void push_object(){
const float OBJECT_VELOCITY = 10.0f;
_body.linearVelocity = Vector3(0.0f, 0.0f, 1.0f) * OBJECT_VELOCITY;
}
}
It works fine if I am not trying to assign it to a pointer. But then I cant call the push_object method from MoveCamera().
I’ve got a couple of other working ScriptObject classes that i tried to assign to a pointer like suggested, and they stopped working. So I am assuming that they arent not meant to be used how I was trying to use it. What I did to achieve what I was trying to achive was just make the above a class, like so:
class Character{
Node@ _node;
RigidBody@ _body;
Character(Scene@ scene){
_node = scene.CreateChild("Character");
StaticModel@ coneObject = _node.CreateComponent("StaticModel");
coneObject.model = cache.GetResource("Model", "Models/Cone.mdl");
coneObject.material = cache.GetResource("Material", "Materials/StoneTiled.xml");
_body = _node.CreateComponent("RigidBody");
_body.mass = 0.25f;
_body.friction = 0.75f;
_body.linearDamping = 0.6f;
_body.useGravity = false;
CollisionShape@ shape = _node.CreateComponent("CollisionShape");
shape.SetBox(Vector3(1.0f, 1.0f, 1.0f));
}
void push_object(){
const float OBJECT_VELOCITY = 10.0f;
_body.linearVelocity = Vector3(0.0f, 0.0f, 1.0f) * OBJECT_VELOCITY;
}
}
And now it is created and the push_object method is called like this (abridged):
Character@ _character;
void CreateScene(){
_scene = Scene();
_character = Character(_scene);//create the character at the scene level
}
void MoveCamera(float timeStep){
if (input.mouseButtonPress[MOUSEB_LEFT]){
_character.push_object();
}
}
And that all works as I would expect.
So i just needed to restructure how I was using classes and thus ScriptObjects.