Cleaned up and commented version.
This commit is contained in:
@@ -3,14 +3,16 @@ using Unity.Cinemachine;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
// Die Zoom-Funktion per Scrollrad musste erst händisch der Orbit-Kamera hinzugefügt werden. Dafür ist dieses Script zuständig.
|
||||
|
||||
public class CinemachinePositionComposerController : MonoBehaviour
|
||||
{
|
||||
[Header("Input Actions")]
|
||||
public InputActionReference zoomAction;
|
||||
public InputActionReference zoomAction; // Zuweisung einer Unity Input System Action.
|
||||
|
||||
public CinemachinePositionComposer positionComposer;
|
||||
public CinemachinePositionComposer positionComposer; // Zuweisung eines Position Composers der manipuliert werden soll.
|
||||
|
||||
private bool zoomBlocked = false;
|
||||
private bool zoomBlocked = false; // Blocker für Zoom (wie schon in OrbitCameraMouseControl).
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
@@ -22,20 +24,20 @@ public class CinemachinePositionComposerController : MonoBehaviour
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (zoomAction != null && !zoomBlocked)
|
||||
{
|
||||
if (zoomAction != null && !zoomBlocked) // Wenn der Blocker nicht aktiv und die Action zugewiesen ist, wird in jedem Frame der Zustand des Scrollrads abgefragt
|
||||
{ // und auf dieser Basis die CameraDistance im Position Composer verändert.
|
||||
Vector2 zoomValue = zoomAction.action.ReadValue<Vector2>();
|
||||
positionComposer.CameraDistance = positionComposer.CameraDistance - zoomValue.y * 0.25f;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void SetBlocker(bool value)
|
||||
public void SetBlocker(bool value) // mit dieser Funktion kann der Blocker durch andere Skripte gesetzt werden.
|
||||
{
|
||||
zoomBlocked = value;
|
||||
}
|
||||
|
||||
public void SetLookahead(bool value)
|
||||
public void SetLookahead(bool value) // Die Aktivierung und Deaktivierung des in Cinemachine möglichen Lookaheads wurde hier ebenfalls untergebracht.
|
||||
{
|
||||
positionComposer.Lookahead.Enabled = value;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user