FollowTargetFromDistance.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #include <CameraFramework/ICameraTransformBehavior.h>
  10. #include <AzCore/RTTI/RTTI.h>
  11. #include <AzCore/Math/Transform.h>
  12. #include <LmbrCentral/Scripting/GameplayNotificationBus.h>
  13. #include <AzCore/Memory/SystemAllocator.h>
  14. namespace AZ
  15. {
  16. class ReflectContext;
  17. }
  18. namespace Camera
  19. {
  20. //////////////////////////////////////////////////////////////////////////
  21. /// This behavior will cause the camera to follow the target by "Follow Distance"
  22. /// meters. Zoom using action events. Use a distance of 0 for FPS style games
  23. /// and a distance greater than 0 for a Third Person style camera
  24. //////////////////////////////////////////////////////////////////////////
  25. class FollowTargetFromDistance
  26. : public ICameraTransformBehavior
  27. , public AZ::GameplayNotificationBus::MultiHandler
  28. {
  29. public:
  30. ~FollowTargetFromDistance() override = default;
  31. AZ_RTTI(FollowTargetFromDistance, "{E6BEDB2C-6812-4369-8C0F-C1E72F380E50}", ICameraTransformBehavior)
  32. AZ_CLASS_ALLOCATOR(FollowTargetFromDistance, AZ::SystemAllocator);
  33. static void Reflect(AZ::ReflectContext* reflection);
  34. //////////////////////////////////////////////////////////////////////////
  35. // ICameraTransformBehavior
  36. void AdjustCameraTransform(float deltaTime, const AZ::Transform& initialCameraTransform, const AZ::Transform& targetTransform, AZ::Transform& inOutCameraTransform) override;
  37. void Activate(AZ::EntityId) override;
  38. void Deactivate() override;
  39. //////////////////////////////////////////////////////////////////////////
  40. // AZ::GameplayNotificationBus
  41. void OnEventBegin(const AZStd::any&) override;
  42. private:
  43. //////////////////////////////////////////////////////////////////////////
  44. // Editor helpers
  45. float GetMinimumFollowDistance() { return m_minFollowDistance; }
  46. float GetMaximumFollowDistance() { return m_maxFollowDistance; }
  47. //////////////////////////////////////////////////////////////////////////
  48. // Reflected Data
  49. float m_minFollowDistance = 0.f;
  50. float m_followDistance = 0.f;
  51. float m_maxFollowDistance = 0.f;
  52. AZStd::string m_zoomInEventName = "";
  53. AZStd::string m_zoomOutEventName = "";
  54. AZ::EntityId m_channelId;
  55. float m_zoomSpeedScale = 1.f;
  56. };
  57. }