GetParent

This function gets an entity's parent entity.

Syntax

Returns

Returns the parent of the entity. If there is no parent, NULL is returned.

Example

#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, -5);

Light* light = DirectionalLight::Create();
light->SetRotation(35, 35, 0);

//Create a model
Entity* entity = Model::Box();

Entity* child = Model::Box(1, 1, 1, entity);
child->SetColor(1.0, 0.0, 0.0);
child->SetPosition(2, -2, 0);

while (true)
{
if (window->Closed() || window->KeyDown(Key::Escape)) return false;

Leadwerks::Leadwerks::Time::Update();
world->Update();
world->Render();

entity->Turn(1.0*Leadwerks::Time::GetSpeed(), 2.0*Leadwerks::Time::GetSpeed(), 3.0*Leadwerks::Time::GetSpeed());

//Get the entity child
Entity* child = entity->GetChild(0);

//Confirm the child's parent is the entity
Debug::Assert(child->GetParent() == entity);

context->Sync();
}
}