From 3be6dee6b8de305ba8a2bb5b0e051c738c558f90 Mon Sep 17 00:00:00 2001 From: Bastian Hofmann Date: Wed, 15 Mar 2023 09:10:51 +0000 Subject: [PATCH] Add way of keeping heading if no target Quaternion is given. --- src/ign_actor_plugin/src/ActorSystem.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/ign_actor_plugin/src/ActorSystem.cpp b/src/ign_actor_plugin/src/ActorSystem.cpp index 8a040a8..048796a 100644 --- a/src/ign_actor_plugin/src/ActorSystem.cpp +++ b/src/ign_actor_plugin/src/ActorSystem.cpp @@ -172,6 +172,15 @@ void ActorSystem::PreUpdate(const UpdateInfo &_info, EntityComponentManager &_ec movementDetails.rotateToTargetDuration = 0.0; movementDetails.moveDuration = 0.0; } + + if( + movementDetails.target.Rot().W() == 0 && + movementDetails.target.Rot().X() == 0 && + movementDetails.target.Rot().Y() == 0 && + movementDetails.target.Rot().Z() == 0 + ){ + movementDetails.target.Rot() = movementDetails.targetDiff.Rot(); + } movementDetails.rotateToEndDuration = Angle(movementDetails.targetDiff.Rot(),movementDetails.target.Rot()) / turnSpeed; }