SpiderPig Posted March 23, 2019 Share Posted March 23, 2019 Not sure if I'm using these right - is GetObjectA() the correct one to use? auto _interaction = new Interaction(); entity->SetObject("interaction", (Object*)_interaction); auto test = entity->GetObjectA("interaction");//retuns NULL I've been using SetUserData() previously but I need more than one object assigned to an entity. Quote Link to comment Share on other sites More sharing options...
Rick Posted March 24, 2019 Share Posted March 24, 2019 17 minutes ago, Lethal Raptor Games said: I've been using SetUserData() previously but I need more than one object assigned to an entity. Then you should be able to make the user data that you set a list of objects that you can add/remove from. Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted March 24, 2019 Author Share Posted March 24, 2019 I thought about that, but it would involve a major rework, if these functions do what I think they're supposed it would be easier. Quote Link to comment Share on other sites More sharing options...
Josh Posted March 24, 2019 Share Posted March 24, 2019 GetObjectA is a Win32 function. Also, you don't need to include the (Object*) cast. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
SpiderPig Posted March 24, 2019 Author Share Posted March 24, 2019 I've tried entity->GetObject() and that returns NULL also. What else is there to try? Do I need to disable something somewhere in the windows macro? Quote Link to comment Share on other sites More sharing options...
Solution Josh Posted March 24, 2019 Solution Share Posted March 24, 2019 A script must be assigned for an entity to contain script properties. Quick test: #include "Leadwerks.h" using namespace Leadwerks; int main(int argc, const char *argv[]) { Leadwerks::Window* window = Leadwerks::Window::Create(); Context* context = Context::Create(window); World* world = World::Create(); Camera* camera = Camera::Create(); camera->SetRotation(35, 0, 0); camera->Move(0, 0, -6); Light* light = DirectionalLight::Create(); light->SetRotation(35, 35, 0); //Create a model Model* model1 = Model::Box(); model1->SetPosition(-1, 0, 0); model1->SetColor(0.0, 0.0, 1.0); //Create a copy Model* model2 = (Model*)model1->Copy(); model2->SetPosition(1, 0, 0); model2->SetColor(0.0, 1.0, 0.0); //Lets modify some vertices to show the copy is unique Surface* surface = model2->GetSurface(0); surface->SetVertexPosition(0, -0.5, -2, -0.5); surface->UpdateAABB(); model2->UpdateAABB(Entity::LocalAABB | Entity::GlobalAABB); model1->SetScript("Scripts/null.lua"); model1->SetObject("TEST", surface); auto a = model1->GetObject("TEST"); Debug::Assert(a == surface); while (true) { if (window->Closed() || window->KeyDown(Key::Escape)) return false; Leadwerks::Time::Update(); world->Update(); world->Render(); context->Sync(); } } 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
SpiderPig Posted March 24, 2019 Author Share Posted March 24, 2019 Ah I see, so the class needs to be derived from Object and SetObejct() is for setting and object in a script. Thanks for the help! Quote Link to comment Share on other sites More sharing options...
Josh Posted March 24, 2019 Share Posted March 24, 2019 In next engine, properties are attached to the entity in Lua, so no script is needed. 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted March 24, 2019 Share Posted March 24, 2019 Spiderpig, spiderpig, doing the things that a spiderpig does... 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.