using System; using UnityEngine; namespace Framework.Actors { /// Component allowing the player to control where an actor is looking /// /// /// There typically are multiple components implementing this interface present on /// an actor, supporting different input profiles (i.e. the look direction in VR is /// controlled by a different component than look direction using the mouse). /// /// /// The actor itself will usually make use of the /// component to route calls to the currently active head controller. /// /// /// Head controllers can store and manage the head orientation on their own terms /// (for example, as pitch and yaw if that covers their needs). When the /// notices a switch to another head controller, /// it will transfer the local head orientation from the old to the new controller. /// /// public interface IHeadController { /// Fired to pass on head rotation that was clamped /// /// /// When the player rotates the character's head beyond its movement range, /// by default the head simply stops. For first person games, it is more /// intuitive (and established practice) to rotate the body so the player can /// use the mouse not only turn the head but also the whole body around. /// Use this event to get notified of head rotation that was clamped off so /// you can apply it to the body. /// /// /// Fancy implementations might even want to watch this event and play /// a "step in place" animation to turn the body completely /// into the direction the player is looking once it reaches the boundaries /// of what pure head movement allows. /// /// event Action ExcessHeadRotation; /// Transform to which the virtual reality camera is parented /// /// /// This should be set only for VR-based head controllers. In Unity, when /// VR is enabled the active camera will always assume the position of /// the player's eyes in the real world (relative to the camera's parent /// transform). /// /// /// So the only way to adjust the position from which the player sees /// the scene is to parent the camera to a transform that can be moved around /// in order to adjust its neutral position. This is called /// a "camera root" and can either be a child of other nodes /// (for example, of a car if the player is driving a car) or scene-global. /// /// /// Head controllers that are not VR or do not work in this fashion will /// simply return null here. /// /// Transform VirtualRealityCameraRoot { get; } /// Base transform in which the player controls the look direction /// /// /// Translates from the global coordinate space into the coordinate space /// in which head movements take place. /// /// /// Depending on the complexity of the look controller used, this may simply be /// the actor transform's orientation or it may be the transform of the neck's parent /// bone (allowing the actor to bow or wobble and altering the head's frame of /// reference accordingly). /// /// Quaternion HeadBaseOrientation { get; } /// Where the player is looking within the head's coordinate space /// /// Append this rotation to the to get the direction /// the player is looking at in the global coordinate frame. /// Quaternion LocalHeadOrientation { get; set; } /// Whether this head controller is in the active input profile /// /// It is not unusual for actors to have multiple head controllers. For example, /// there might be a mouse look head controller and a virtual reality head controller /// that are switched between depending on the input profile the game runs with. /// This property allows the actor controller to figure out which one to talk to. /// bool IsActive { get; } } } // namespace Framework.Actors