This commit is contained in:
Aaron Kimbre 2023-04-03 08:29:39 -05:00
parent a5ff93351d
commit dffcbcd4d4

View File

@ -15,17 +15,13 @@ void ChangeOrientationBehavior::Calculate(BehaviorContext* context, RakNet::BitS
else destinationEntity = EntityManager::Instance()->GetEntity(context->originator); else destinationEntity = EntityManager::Instance()->GetEntity(context->originator);
if (!destinationEntity) return; if (!destinationEntity) return;
const auto source = sourceEntity->GetPosition(); sourceEntity->SetRotation(
const auto destination = destinationEntity->GetPosition(); NiQuaternion::LookAt(sourceEntity->GetPosition(), destinationEntity->GetPosition())
sourceEntity->SetRotation(NiQuaternion::LookAt(source, destination)); );
} else if (this->m_toAngle){ } else if (this->m_toAngle){
auto baseAngle = NiPoint3(this->m_angle, 0, 0); auto baseAngle = NiPoint3(this->m_angle, 0, 0);
if (this->m_relative){ if (this->m_relative) baseAngle += sourceEntity->GetRotation().GetEulerAngles();
auto sourceAngle = sourceEntity->GetRotation().GetEulerAngles(); sourceEntity->SetRotation(NiQuaternion::FromEulerAngles(baseAngle));
baseAngle += sourceAngle;
}
auto newRotation = NiQuaternion::FromEulerAngles(baseAngle);
sourceEntity->SetRotation(newRotation);
} else return; } else return;
EntityManager::Instance()->SerializeEntity(sourceEntity); EntityManager::Instance()->SerializeEntity(sourceEntity);
return; return;