From d0d2e1f3438fd272a72bc21cd3b60115480c91d0 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Tue, 8 Apr 2025 18:30:06 -0500 Subject: [PATCH] handle relfecting the health of the controlled object players and vehicles can both be the controlobject, or you can control a vehicle *through* a player. set the health bar/text controls to reflect that state --- Engine/source/T3D/fps/guiHealthBarHud.cpp | 5 +++++ Engine/source/T3D/fps/guiHealthTextHud.cpp | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Engine/source/T3D/fps/guiHealthBarHud.cpp b/Engine/source/T3D/fps/guiHealthBarHud.cpp index 602d242b1..79b420e3a 100644 --- a/Engine/source/T3D/fps/guiHealthBarHud.cpp +++ b/Engine/source/T3D/fps/guiHealthBarHud.cpp @@ -147,6 +147,11 @@ void GuiHealthBarHud::onRender(Point2I offset, const RectI &updateRect) if (!conn) return; ShapeBase* control = dynamic_cast(conn->getControlObject()); + + //cover the case of a connection controling an object in turn controlling another + if (control && control->getControlObject()) + control = control->getControlObject(); + if (!control || !(control->getTypeMask() & (PlayerObjectType | VehicleObjectType))) return; diff --git a/Engine/source/T3D/fps/guiHealthTextHud.cpp b/Engine/source/T3D/fps/guiHealthTextHud.cpp index 1c202906c..faa798253 100644 --- a/Engine/source/T3D/fps/guiHealthTextHud.cpp +++ b/Engine/source/T3D/fps/guiHealthTextHud.cpp @@ -148,7 +148,12 @@ void GuiHealthTextHud::onRender(Point2I offset, const RectI &updateRect) GameConnection* conn = GameConnection::getConnectionToServer(); if (!conn) return; - ShapeBase* control = dynamic_cast(conn->getControlObject()); + ShapeBase* control = dynamic_cast(conn->getControlObject()); + + //cover the case of a connection controling an object in turn controlling another + if (control && control->getControlObject()) + control = control->getControlObject(); + if (!control || !(control->getTypeMask() & (PlayerObjectType | VehicleObjectType))) return;