Jump to content

Entity::SetObject()


Go to solution Solved by Josh,

Recommended Posts

Posted

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.

Posted
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.

Posted

GetObjectA is a Win32 function.

Also, you don't need to include the (Object*) cast.

My job is to make tools you love, with the features you want, and performance you can't live without.

  • Solution
Posted

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();
	}
}

 

  • Thanks 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Posted

In next engine, properties are attached to the entity in Lua, so no script is needed.

  • Like 1

My job is to make tools you love, with the features you want, and performance you can't live without.

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...