Is there way to spawn entity's component onto level?

0

Is there way to dynamically spawn entity component onto level from C++ ?

ley's say I have my own component(MyComponent) and I want to spawning few copies of it, onto level into various world's positions, how to do that ?

asked 5 years ago188 views
3 Answers
0
Accepted Answer

Hi fluffy. You can use some code like this.


AZ::Entity* newEntity = aznew AZ::Entity("testEntity");
newEntity->CreateComponent("{22B10178-39B6-4C12-BB37-77DB45FDD3B6}"); // transform component
newEntity->CreateComponent("{.....}"); // your component uuid
newEntity->Init();
newEntity->Activate();
AZ::Vector3 pos(0.0f, 0.0f, 0.0f); // position
AZ::TransformBus::Event(newEntity->GetEntityId(), &AZ::TransformInterface::SetWorldTM, AZ::Transform::CreateTranslation(pos));

Hope, that help to you :)

answered 5 years ago
0

Thanks for tip ! Can we just use name of components instead of those uuid numbers ?

answered 5 years ago
0

No only uuid of component. Name using just for debugging and not using in create process, how far i know.

answered 5 years ago

This post is closed: Adding new answers, comments, and votes is disabled.