Skip to content
Snippets Groups Projects
Commit 6b64dbcd authored by Sebastian Freitag's avatar Sebastian Freitag
Browse files

fix crash when there are no appropriate runtime entities in the scene

parent 9855a7e4
No related branches found
No related tags found
1 merge request!81Feature/#296 user platform
...@@ -31,12 +31,18 @@ void ControllerBehavior::OnUpdate() { ...@@ -31,12 +31,18 @@ void ControllerBehavior::OnUpdate() {
phx::Scene* scene = GetEntity()->GetScene(); phx::Scene* scene = GetEntity()->GetScene();
phx::Entity* runtime_entity = nullptr; phx::Entity* runtime_entity = nullptr;
if (side_ == Side::LEFT) { if (side_ == Side::LEFT) {
runtime_entity = scene->GetEntitiesWithComponents< auto runtime_entities = scene->GetEntitiesWithComponents<
phx::RuntimeComponent<phx::LEFT_CONTROLLER>>()[0]; phx::RuntimeComponent<phx::LEFT_CONTROLLER>>();
if (!runtime_entities.empty()) {
runtime_entity = runtime_entities[0];
}
} }
if (side_ == Side::RIGHT) { if (side_ == Side::RIGHT) {
runtime_entity = scene->GetEntitiesWithComponents< auto runtime_entities = scene->GetEntitiesWithComponents<
phx::RuntimeComponent<phx::RIGHT_CONTROLLER>>()[0]; phx::RuntimeComponent<phx::RIGHT_CONTROLLER>>();
if (!runtime_entities.empty()) {
runtime_entity = runtime_entities[0];
}
} }
if (runtime_entity && if (runtime_entity &&
!(GetEntity()->GetFirstComponent<phx::Transform>()->GetParent() == !(GetEntity()->GetFirstComponent<phx::Transform>()->GetParent() ==
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment