Camera locking when its transform is locked (#5996)

* Locking the camera when its entity transform is locked

Signed-off-by: AMZN-Igarri <82394219+AMZN-Igarri@users.noreply.github.com>

* Added function to unposses camera when transform locks

Signed-off-by: AMZN-Igarri <82394219+AMZN-Igarri@users.noreply.github.com>

* Basic camera behaviour

Signed-off-by: AMZN-Igarri <82394219+AMZN-Igarri@users.noreply.github.com>

* Addressed codereview suggestions

Signed-off-by: AMZN-Igarri <82394219+AMZN-Igarri@users.noreply.github.com>
This commit is contained in:
AMZN-Igarri
2021-11-30 10:39:07 +01:00
committed by GitHub
parent 3922280cec
commit 271004635c
3 changed files with 23 additions and 2 deletions
@@ -18,6 +18,7 @@
#include <Atom/RPI.Public/ViewportContext.h>
#include <Atom/RPI.Public/View.h>
#include <AzToolsFramework/ToolsComponents/TransformComponent.h>
namespace Camera
{
@@ -41,6 +42,16 @@ namespace Camera
return isInGameMode;
});
// Only allow our camera to move when the transform is not locked.
m_controller.SetIsLockedFunction([this]()
{
bool locked = false;
AzToolsFramework::Components::TransformComponentMessages::Bus::EventResult(
locked, GetEntityId(), &AzToolsFramework::Components::TransformComponentMessages::IsTransformLocked);
return locked;
});
// Call base class activate, which in turn calls Activate on our controller.
EditorCameraComponentBase::Activate();