0% found this document useful (0 votes)
43 views63 pages

Sinonomple Camera Controller

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views63 pages

Sinonomple Camera Controller

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

#if ENABLE_INPUT_SYSTEM && ENABLE_INPUT_SYSTEM_PACKAGE

#define USE_INPUT_SYSTEM
using [Link];
using [Link];
#endif

using UnityEngine;

namespace UnityTemplateProjects
{
public class SimpleCameraController : MonoBehaviour
{
class CameraState
{
public float yaw;
public float pitch;
public float roll;
public float x;
public float y;
public float z;

public void SetFromTransform(Transform t)


{
pitch = [Link].x;
yaw = [Link].y;
roll = [Link].z;
x = [Link].x;
y = [Link].y;
z = [Link].z;
}

public void Translate(Vector3 translation)


{
Vector3 rotatedTranslation = [Link](pitch, yaw, roll) *
translation;

x += rotatedTranslation.x;
y += rotatedTranslation.y;
z += rotatedTranslation.z;
}

public void LerpTowards(CameraState target, float positionLerpPct,


float rotationLerpPct)
{
yaw = [Link](yaw, [Link], rotationLerpPct);
pitch = [Link](pitch, [Link], rotationLerpPct);
roll = [Link](roll, [Link], rotationLerpPct);

x = [Link](x, target.x, positionLerpPct);


y = [Link](y, target.y, positionLerpPct);
z = [Link](z, target.z, positionLerpPct);
}

public void UpdateTransform(Transform t)


{
[Link] = new Vector3(pitch, yaw, roll);
[Link] = new Vector3(x, y, z);
}
}
CameraState m_TargetCameraState = new CameraState();
CameraState m_InterpolatingCameraState = new CameraState();

[Header("Movement Settings")]
[Tooltip("Exponential boost factor on translation, controllable by mouse
wheel.")]
public float boost = 3.5f;

[Tooltip("Time it takes to interpolate camera position 99% of the way to


the target."), Range(0.001f, 1f)]
public float positionLerpTime = 0.2f;

[Header("Rotation Settings")]
[Tooltip("X = Change in mouse position.\nY = Multiplicative factor for
camera rotation.")]
public AnimationCurve mouseSensitivityCurve = new AnimationCurve(new
Keyframe(0f, 0.5f, 0f, 5f), new Keyframe(1f, 2.5f, 0f, 0f));

[Tooltip("Time it takes to interpolate camera rotation 99% of the way to


the target."), Range(0.001f, 1f)]
public float rotationLerpTime = 0.01f;

[Tooltip("Whether or not to invert our Y axis for mouse input to


rotation.")]
public bool invertY = false;

void OnEnable()
{
m_TargetCameraState.SetFromTransform(transform);
m_InterpolatingCameraState.SetFromTransform(transform);
}

Vector3 GetInputTranslationDirection()
{
Vector3 direction = new Vector3();
if ([Link](KeyCode.W))
{
direction += [Link];
}
if ([Link](KeyCode.S))
{
direction += [Link];
}
if ([Link](KeyCode.A))
{
direction += [Link];
}
if ([Link](KeyCode.D))
{
direction += [Link];
}
if ([Link](KeyCode.Q))
{
direction += [Link];
}
if ([Link](KeyCode.E))
{
direction += [Link];
}
return direction;
}

void Update()
{
Vector3 translation = [Link];

#if ENABLE_LEGACY_INPUT_MANAGER

// Exit Sample
if ([Link]([Link]))
{
[Link]();
#if UNITY_EDITOR
[Link] = false;
#endif
}
// Hide and lock cursor when right mouse button pressed
if ([Link](1))
{
[Link] = [Link];
}

// Unlock and show cursor when right mouse button released


if ([Link](1))
{
[Link] = true;
[Link] = [Link];
}

// Rotation
if ([Link](1))
{
var mouseMovement = new Vector2([Link]("Mouse X"),
[Link]("Mouse Y") * (invertY ? 1 : -1));

var mouseSensitivityFactor =
[Link]([Link]);

m_TargetCameraState.yaw += mouseMovement.x *
mouseSensitivityFactor;
m_TargetCameraState.pitch += mouseMovement.y *
mouseSensitivityFactor;
}

// Translation
translation = GetInputTranslationDirection() * [Link];

// Speed up movement when shift key held


if ([Link]([Link]))
{
translation *= 10.0f;
}

// Modify movement by a boost factor (defined in Inspector and modified


in play mode through the mouse scroll wheel)
boost += [Link].y * 0.2f;
translation *= [Link](2.0f, boost);
#elif USE_INPUT_SYSTEM
// TODO: make the new input system work
#endif

m_TargetCameraState.Translate(translation);

// Framerate-independent interpolation
// Calculate the lerp amount, such that we get 99% of the way to our
target in the specified time
var positionLerpPct = 1f - [Link](([Link](1f - 0.99f) /
positionLerpTime) * [Link]);
var rotationLerpPct = 1f - [Link](([Link](1f - 0.99f) /
rotationLerpTime) * [Link]);
m_InterpolatingCameraState.LerpTowards(m_TargetCameraState,
positionLerpPct, rotationLerpPct);

m_InterpolatingCameraState.UpdateTransform(transform);
}
}

}#if ENABLE_INPUT_SYSTEM && ENABLE_INPUT_SYSTEM_PACKAGE


#define USE_INPUT_SYSTEM
using [Link];
using [Link];
#endif

using UnityEngine;

namespace UnityTemplateProjects
{
public class SimpleCameraController : MonoBehaviour
{
class CameraState
{
public float yaw;
public float pitch;
public float roll;
public float x;
public float y;
public float z;

public void SetFromTransform(Transform t)


{
pitch = [Link].x;
yaw = [Link].y;
roll = [Link].z;
x = [Link].x;
y = [Link].y;
z = [Link].z;
}

public void Translate(Vector3 translation)


{
Vector3 rotatedTranslation = [Link](pitch, yaw, roll) *
translation;

x += rotatedTranslation.x;
y += rotatedTranslation.y;
z += rotatedTranslation.z;
}

public void LerpTowards(CameraState target, float positionLerpPct,


float rotationLerpPct)
{
yaw = [Link](yaw, [Link], rotationLerpPct);
pitch = [Link](pitch, [Link], rotationLerpPct);
roll = [Link](roll, [Link], rotationLerpPct);

x = [Link](x, target.x, positionLerpPct);


y = [Link](y, target.y, positionLerpPct);
z = [Link](z, target.z, positionLerpPct);
}

public void UpdateTransform(Transform t)


{
[Link] = new Vector3(pitch, yaw, roll);
[Link] = new Vector3(x, y, z);
}
}

CameraState m_TargetCameraState = new CameraState();


CameraState m_InterpolatingCameraState = new CameraState();

[Header("Movement Settings")]
[Tooltip("Exponential boost factor on translation, controllable by mouse
wheel.")]
public float boost = 3.5f;

[Tooltip("Time it takes to interpolate camera position 99% of the way to


the target."), Range(0.001f, 1f)]
public float positionLerpTime = 0.2f;

[Header("Rotation Settings")]
[Tooltip("X = Change in mouse position.\nY = Multiplicative factor for
camera rotation.")]
public AnimationCurve mouseSensitivityCurve = new AnimationCurve(new
Keyframe(0f, 0.5f, 0f, 5f), new Keyframe(1f, 2.5f, 0f, 0f));

[Tooltip("Time it takes to interpolate camera rotation 99% of the way to


the target."), Range(0.001f, 1f)]
public float rotationLerpTime = 0.01f;

[Tooltip("Whether or not to invert our Y axis for mouse input to


rotation.")]
public bool invertY = false;

void OnEnable()
{
m_TargetCameraState.SetFromTransform(transform);
m_InterpolatingCameraState.SetFromTransform(transform);
}

Vector3 GetInputTranslationDirection()
{
Vector3 direction = new Vector3();
if ([Link](KeyCode.W))
{
direction += [Link];
}
if ([Link](KeyCode.S))
{
direction += [Link];
}
if ([Link](KeyCode.A))
{
direction += [Link];
}
if ([Link](KeyCode.D))
{
direction += [Link];
}
if ([Link](KeyCode.Q))
{
direction += [Link];
}
if ([Link](KeyCode.E))
{
direction += [Link];
}
return direction;
}

void Update()
{
Vector3 translation = [Link];

#if ENABLE_LEGACY_INPUT_MANAGER

// Exit Sample
if ([Link]([Link]))
{
[Link]();
#if UNITY_EDITOR
[Link] = false;
#endif
}
// Hide and lock cursor when right mouse button pressed
if ([Link](1))
{
[Link] = [Link];
}

// Unlock and show cursor when right mouse button released


if ([Link](1))
{
[Link] = true;
[Link] = [Link];
}

// Rotation
if ([Link](1))
{
var mouseMovement = new Vector2([Link]("Mouse X"),
[Link]("Mouse Y") * (invertY ? 1 : -1));

var mouseSensitivityFactor =
[Link]([Link]);

m_TargetCameraState.yaw += mouseMovement.x *
mouseSensitivityFactor;
m_TargetCameraState.pitch += mouseMovement.y *
mouseSensitivityFactor;
}

// Translation
translation = GetInputTranslationDirection() * [Link];

// Speed up movement when shift key held


if ([Link]([Link]))
{
translation *= 10.0f;
}

// Modify movement by a boost factor (defined in Inspector and modified


in play mode through the mouse scroll wheel)
boost += [Link].y * 0.2f;
translation *= [Link](2.0f, boost);

#elif USE_INPUT_SYSTEM
// TODO: make the new input system work
#endif

m_TargetCameraState.Translate(translation);

// Framerate-independent interpolation
// Calculate the lerp amount, such that we get 99% of the way to our
target in the specified time
var positionLerpPct = 1f - [Link](([Link](1f - 0.99f) /
positionLerpTime) * [Link]);
var rotationLerpPct = 1f - [Link](([Link](1f - 0.99f) /
rotationLerpTime) * [Link]);
m_InterpolatingCameraState.LerpTowards(m_TargetCameraState,
positionLerpPct, rotationLerpPct);

m_InterpolatingCameraState.UpdateTransform(transform);
}
}

}#if ENABLE_INPUT_SYSTEM && ENABLE_INPUT_SYSTEM_PACKAGE


#define USE_INPUT_SYSTEM
using [Link];
using [Link];
#endif

using UnityEngine;

namespace UnityTemplateProjects
{
public class SimpleCameraController : MonoBehaviour
{
class CameraState
{
public float yaw;
public float pitch;
public float roll;
public float x;
public float y;
public float z;

public void SetFromTransform(Transform t)


{
pitch = [Link].x;
yaw = [Link].y;
roll = [Link].z;
x = [Link].x;
y = [Link].y;
z = [Link].z;
}

public void Translate(Vector3 translation)


{
Vector3 rotatedTranslation = [Link](pitch, yaw, roll) *
translation;

x += rotatedTranslation.x;
y += rotatedTranslation.y;
z += rotatedTranslation.z;
}

public void LerpTowards(CameraState target, float positionLerpPct,


float rotationLerpPct)
{
yaw = [Link](yaw, [Link], rotationLerpPct);
pitch = [Link](pitch, [Link], rotationLerpPct);
roll = [Link](roll, [Link], rotationLerpPct);

x = [Link](x, target.x, positionLerpPct);


y = [Link](y, target.y, positionLerpPct);
z = [Link](z, target.z, positionLerpPct);
}

public void UpdateTransform(Transform t)


{
[Link] = new Vector3(pitch, yaw, roll);
[Link] = new Vector3(x, y, z);
}
}

CameraState m_TargetCameraState = new CameraState();


CameraState m_InterpolatingCameraState = new CameraState();

[Header("Movement Settings")]
[Tooltip("Exponential boost factor on translation, controllable by mouse
wheel.")]
public float boost = 3.5f;

[Tooltip("Time it takes to interpolate camera position 99% of the way to


the target."), Range(0.001f, 1f)]
public float positionLerpTime = 0.2f;

[Header("Rotation Settings")]
[Tooltip("X = Change in mouse position.\nY = Multiplicative factor for
camera rotation.")]
public AnimationCurve mouseSensitivityCurve = new AnimationCurve(new
Keyframe(0f, 0.5f, 0f, 5f), new Keyframe(1f, 2.5f, 0f, 0f));

[Tooltip("Time it takes to interpolate camera rotation 99% of the way to


the target."), Range(0.001f, 1f)]
public float rotationLerpTime = 0.01f;

[Tooltip("Whether or not to invert our Y axis for mouse input to


rotation.")]
public bool invertY = false;

void OnEnable()
{
m_TargetCameraState.SetFromTransform(transform);
m_InterpolatingCameraState.SetFromTransform(transform);
}

Vector3 GetInputTranslationDirection()
{
Vector3 direction = new Vector3();
if ([Link](KeyCode.W))
{
direction += [Link];
}
if ([Link](KeyCode.S))
{
direction += [Link];
}
if ([Link](KeyCode.A))
{
direction += [Link];
}
if ([Link](KeyCode.D))
{
direction += [Link];
}
if ([Link](KeyCode.Q))
{
direction += [Link];
}
if ([Link](KeyCode.E))
{
direction += [Link];
}
return direction;
}

void Update()
{
Vector3 translation = [Link];

#if ENABLE_LEGACY_INPUT_MANAGER

// Exit Sample
if ([Link]([Link]))
{
[Link]();
#if UNITY_EDITOR
[Link] = false;
#endif
}
// Hide and lock cursor when right mouse button pressed
if ([Link](1))
{
[Link] = [Link];
}

// Unlock and show cursor when right mouse button released


if ([Link](1))
{
[Link] = true;
[Link] = [Link];
}

// Rotation
if ([Link](1))
{
var mouseMovement = new Vector2([Link]("Mouse X"),
[Link]("Mouse Y") * (invertY ? 1 : -1));

var mouseSensitivityFactor =
[Link]([Link]);

m_TargetCameraState.yaw += mouseMovement.x *
mouseSensitivityFactor;
m_TargetCameraState.pitch += mouseMovement.y *
mouseSensitivityFactor;
}

// Translation
translation = GetInputTranslationDirection() * [Link];

// Speed up movement when shift key held


if ([Link]([Link]))
{
translation *= 10.0f;
}

// Modify movement by a boost factor (defined in Inspector and modified


in play mode through the mouse scroll wheel)
boost += [Link].y * 0.2f;
translation *= [Link](2.0f, boost);

#elif USE_INPUT_SYSTEM
// TODO: make the new input system work
#endif

m_TargetCameraState.Translate(translation);

// Framerate-independent interpolation
// Calculate the lerp amount, such that we get 99% of the way to our
target in the specified time
var positionLerpPct = 1f - [Link](([Link](1f - 0.99f) /
positionLerpTime) * [Link]);
var rotationLerpPct = 1f - [Link](([Link](1f - 0.99f) /
rotationLerpTime) * [Link]);
m_InterpolatingCameraState.LerpTowards(m_TargetCameraState,
positionLerpPct, rotationLerpPct);
m_InterpolatingCameraState.UpdateTransform(transform);
}
}

}#if ENABLE_INPUT_SYSTEM && ENABLE_INPUT_SYSTEM_PACKAGE


#define USE_INPUT_SYSTEM
using [Link];
using [Link];
#endif

using UnityEngine;

namespace UnityTemplateProjects
{
public class SimpleCameraController : MonoBehaviour
{
class CameraState
{
public float yaw;
public float pitch;
public float roll;
public float x;
public float y;
public float z;

public void SetFromTransform(Transform t)


{
pitch = [Link].x;
yaw = [Link].y;
roll = [Link].z;
x = [Link].x;
y = [Link].y;
z = [Link].z;
}

public void Translate(Vector3 translation)


{
Vector3 rotatedTranslation = [Link](pitch, yaw, roll) *
translation;

x += rotatedTranslation.x;
y += rotatedTranslation.y;
z += rotatedTranslation.z;
}

public void LerpTowards(CameraState target, float positionLerpPct,


float rotationLerpPct)
{
yaw = [Link](yaw, [Link], rotationLerpPct);
pitch = [Link](pitch, [Link], rotationLerpPct);
roll = [Link](roll, [Link], rotationLerpPct);

x = [Link](x, target.x, positionLerpPct);


y = [Link](y, target.y, positionLerpPct);
z = [Link](z, target.z, positionLerpPct);
}

public void UpdateTransform(Transform t)


{
[Link] = new Vector3(pitch, yaw, roll);
[Link] = new Vector3(x, y, z);
}
}

CameraState m_TargetCameraState = new CameraState();


CameraState m_InterpolatingCameraState = new CameraState();

[Header("Movement Settings")]
[Tooltip("Exponential boost factor on translation, controllable by mouse
wheel.")]
public float boost = 3.5f;

[Tooltip("Time it takes to interpolate camera position 99% of the way to


the target."), Range(0.001f, 1f)]
public float positionLerpTime = 0.2f;

[Header("Rotation Settings")]
[Tooltip("X = Change in mouse position.\nY = Multiplicative factor for
camera rotation.")]
public AnimationCurve mouseSensitivityCurve = new AnimationCurve(new
Keyframe(0f, 0.5f, 0f, 5f), new Keyframe(1f, 2.5f, 0f, 0f));

[Tooltip("Time it takes to interpolate camera rotation 99% of the way to


the target."), Range(0.001f, 1f)]
public float rotationLerpTime = 0.01f;

[Tooltip("Whether or not to invert our Y axis for mouse input to


rotation.")]
public bool invertY = false;

void OnEnable()
{
m_TargetCameraState.SetFromTransform(transform);
m_InterpolatingCameraState.SetFromTransform(transform);
}

Vector3 GetInputTranslationDirection()
{
Vector3 direction = new Vector3();
if ([Link](KeyCode.W))
{
direction += [Link];
}
if ([Link](KeyCode.S))
{
direction += [Link];
}
if ([Link](KeyCode.A))
{
direction += [Link];
}
if ([Link](KeyCode.D))
{
direction += [Link];
}
if ([Link](KeyCode.Q))
{
direction += [Link];
}
if ([Link](KeyCode.E))
{
direction += [Link];
}
return direction;
}

void Update()
{
Vector3 translation = [Link];

#if ENABLE_LEGACY_INPUT_MANAGER

// Exit Sample
if ([Link]([Link]))
{
[Link]();
#if UNITY_EDITOR
[Link] = false;
#endif
}
// Hide and lock cursor when right mouse button pressed
if ([Link](1))
{
[Link] = [Link];
}

// Unlock and show cursor when right mouse button released


if ([Link](1))
{
[Link] = true;
[Link] = [Link];
}

// Rotation
if ([Link](1))
{
var mouseMovement = new Vector2([Link]("Mouse X"),
[Link]("Mouse Y") * (invertY ? 1 : -1));

var mouseSensitivityFactor =
[Link]([Link]);

m_TargetCameraState.yaw += mouseMovement.x *
mouseSensitivityFactor;
m_TargetCameraState.pitch += mouseMovement.y *
mouseSensitivityFactor;
}

// Translation
translation = GetInputTranslationDirection() * [Link];

// Speed up movement when shift key held


if ([Link]([Link]))
{
translation *= 10.0f;
}
// Modify movement by a boost factor (defined in Inspector and modified
in play mode through the mouse scroll wheel)
boost += [Link].y * 0.2f;
translation *= [Link](2.0f, boost);

#elif USE_INPUT_SYSTEM
// TODO: make the new input system work
#endif

m_TargetCameraState.Translate(translation);

// Framerate-independent interpolation
// Calculate the lerp amount, such that we get 99% of the way to our
target in the specified time
var positionLerpPct = 1f - [Link](([Link](1f - 0.99f) /
positionLerpTime) * [Link]);
var rotationLerpPct = 1f - [Link](([Link](1f - 0.99f) /
rotationLerpTime) * [Link]);
m_InterpolatingCameraState.LerpTowards(m_TargetCameraState,
positionLerpPct, rotationLerpPct);

m_InterpolatingCameraState.UpdateTransform(transform);
}
}

}#if ENABLE_INPUT_SYSTEM && ENABLE_INPUT_SYSTEM_PACKAGE


#define USE_INPUT_SYSTEM
using [Link];
using [Link];
#endif

using UnityEngine;

namespace UnityTemplateProjects
{
public class SimpleCameraController : MonoBehaviour
{
class CameraState
{
public float yaw;
public float pitch;
public float roll;
public float x;
public float y;
public float z;

public void SetFromTransform(Transform t)


{
pitch = [Link].x;
yaw = [Link].y;
roll = [Link].z;
x = [Link].x;
y = [Link].y;
z = [Link].z;
}

public void Translate(Vector3 translation)


{
Vector3 rotatedTranslation = [Link](pitch, yaw, roll) *
translation;

x += rotatedTranslation.x;
y += rotatedTranslation.y;
z += rotatedTranslation.z;
}

public void LerpTowards(CameraState target, float positionLerpPct,


float rotationLerpPct)
{
yaw = [Link](yaw, [Link], rotationLerpPct);
pitch = [Link](pitch, [Link], rotationLerpPct);
roll = [Link](roll, [Link], rotationLerpPct);

x = [Link](x, target.x, positionLerpPct);


y = [Link](y, target.y, positionLerpPct);
z = [Link](z, target.z, positionLerpPct);
}

public void UpdateTransform(Transform t)


{
[Link] = new Vector3(pitch, yaw, roll);
[Link] = new Vector3(x, y, z);
}
}

CameraState m_TargetCameraState = new CameraState();


CameraState m_InterpolatingCameraState = new CameraState();

[Header("Movement Settings")]
[Tooltip("Exponential boost factor on translation, controllable by mouse
wheel.")]
public float boost = 3.5f;

[Tooltip("Time it takes to interpolate camera position 99% of the way to


the target."), Range(0.001f, 1f)]
public float positionLerpTime = 0.2f;

[Header("Rotation Settings")]
[Tooltip("X = Change in mouse position.\nY = Multiplicative factor for
camera rotation.")]
public AnimationCurve mouseSensitivityCurve = new AnimationCurve(new
Keyframe(0f, 0.5f, 0f, 5f), new Keyframe(1f, 2.5f, 0f, 0f));

[Tooltip("Time it takes to interpolate camera rotation 99% of the way to


the target."), Range(0.001f, 1f)]
public float rotationLerpTime = 0.01f;

[Tooltip("Whether or not to invert our Y axis for mouse input to


rotation.")]
public bool invertY = false;

void OnEnable()
{
m_TargetCameraState.SetFromTransform(transform);
m_InterpolatingCameraState.SetFromTransform(transform);
}

Vector3 GetInputTranslationDirection()
{
Vector3 direction = new Vector3();
if ([Link](KeyCode.W))
{
direction += [Link];
}
if ([Link](KeyCode.S))
{
direction += [Link];
}
if ([Link](KeyCode.A))
{
direction += [Link];
}
if ([Link](KeyCode.D))
{
direction += [Link];
}
if ([Link](KeyCode.Q))
{
direction += [Link];
}
if ([Link](KeyCode.E))
{
direction += [Link];
}
return direction;
}

void Update()
{
Vector3 translation = [Link];

#if ENABLE_LEGACY_INPUT_MANAGER

// Exit Sample
if ([Link]([Link]))
{
[Link]();
#if UNITY_EDITOR
[Link] = false;
#endif
}
// Hide and lock cursor when right mouse button pressed
if ([Link](1))
{
[Link] = [Link];
}

// Unlock and show cursor when right mouse button released


if ([Link](1))
{
[Link] = true;
[Link] = [Link];
}

// Rotation
if ([Link](1))
{
var mouseMovement = new Vector2([Link]("Mouse X"),
[Link]("Mouse Y") * (invertY ? 1 : -1));

var mouseSensitivityFactor =
[Link]([Link]);

m_TargetCameraState.yaw += mouseMovement.x *
mouseSensitivityFactor;
m_TargetCameraState.pitch += mouseMovement.y *
mouseSensitivityFactor;
}

// Translation
translation = GetInputTranslationDirection() * [Link];

// Speed up movement when shift key held


if ([Link]([Link]))
{
translation *= 10.0f;
}

// Modify movement by a boost factor (defined in Inspector and modified


in play mode through the mouse scroll wheel)
boost += [Link].y * 0.2f;
translation *= [Link](2.0f, boost);

#elif USE_INPUT_SYSTEM
// TODO: make the new input system work
#endif

m_TargetCameraState.Translate(translation);

// Framerate-independent interpolation
// Calculate the lerp amount, such that we get 99% of the way to our
target in the specified time
var positionLerpPct = 1f - [Link](([Link](1f - 0.99f) /
positionLerpTime) * [Link]);
var rotationLerpPct = 1f - [Link](([Link](1f - 0.99f) /
rotationLerpTime) * [Link]);
m_InterpolatingCameraState.LerpTowards(m_TargetCameraState,
positionLerpPct, rotationLerpPct);

m_InterpolatingCameraState.UpdateTransform(transform);
}
}

}#if ENABLE_INPUT_SYSTEM && ENABLE_INPUT_SYSTEM_PACKAGE


#define USE_INPUT_SYSTEM
using [Link];
using [Link];
#endif

using UnityEngine;

namespace UnityTemplateProjects
{
public class SimpleCameraController : MonoBehaviour
{
class CameraState
{
public float yaw;
public float pitch;
public float roll;
public float x;
public float y;
public float z;

public void SetFromTransform(Transform t)


{
pitch = [Link].x;
yaw = [Link].y;
roll = [Link].z;
x = [Link].x;
y = [Link].y;
z = [Link].z;
}

public void Translate(Vector3 translation)


{
Vector3 rotatedTranslation = [Link](pitch, yaw, roll) *
translation;

x += rotatedTranslation.x;
y += rotatedTranslation.y;
z += rotatedTranslation.z;
}

public void LerpTowards(CameraState target, float positionLerpPct,


float rotationLerpPct)
{
yaw = [Link](yaw, [Link], rotationLerpPct);
pitch = [Link](pitch, [Link], rotationLerpPct);
roll = [Link](roll, [Link], rotationLerpPct);

x = [Link](x, target.x, positionLerpPct);


y = [Link](y, target.y, positionLerpPct);
z = [Link](z, target.z, positionLerpPct);
}

public void UpdateTransform(Transform t)


{
[Link] = new Vector3(pitch, yaw, roll);
[Link] = new Vector3(x, y, z);
}
}

CameraState m_TargetCameraState = new CameraState();


CameraState m_InterpolatingCameraState = new CameraState();

[Header("Movement Settings")]
[Tooltip("Exponential boost factor on translation, controllable by mouse
wheel.")]
public float boost = 3.5f;

[Tooltip("Time it takes to interpolate camera position 99% of the way to


the target."), Range(0.001f, 1f)]
public float positionLerpTime = 0.2f;
[Header("Rotation Settings")]
[Tooltip("X = Change in mouse position.\nY = Multiplicative factor for
camera rotation.")]
public AnimationCurve mouseSensitivityCurve = new AnimationCurve(new
Keyframe(0f, 0.5f, 0f, 5f), new Keyframe(1f, 2.5f, 0f, 0f));

[Tooltip("Time it takes to interpolate camera rotation 99% of the way to


the target."), Range(0.001f, 1f)]
public float rotationLerpTime = 0.01f;

[Tooltip("Whether or not to invert our Y axis for mouse input to


rotation.")]
public bool invertY = false;

void OnEnable()
{
m_TargetCameraState.SetFromTransform(transform);
m_InterpolatingCameraState.SetFromTransform(transform);
}

Vector3 GetInputTranslationDirection()
{
Vector3 direction = new Vector3();
if ([Link](KeyCode.W))
{
direction += [Link];
}
if ([Link](KeyCode.S))
{
direction += [Link];
}
if ([Link](KeyCode.A))
{
direction += [Link];
}
if ([Link](KeyCode.D))
{
direction += [Link];
}
if ([Link](KeyCode.Q))
{
direction += [Link];
}
if ([Link](KeyCode.E))
{
direction += [Link];
}
return direction;
}

void Update()
{
Vector3 translation = [Link];

#if ENABLE_LEGACY_INPUT_MANAGER

// Exit Sample
if ([Link]([Link]))
{
[Link]();
#if UNITY_EDITOR
[Link] = false;
#endif
}
// Hide and lock cursor when right mouse button pressed
if ([Link](1))
{
[Link] = [Link];
}

// Unlock and show cursor when right mouse button released


if ([Link](1))
{
[Link] = true;
[Link] = [Link];
}

// Rotation
if ([Link](1))
{
var mouseMovement = new Vector2([Link]("Mouse X"),
[Link]("Mouse Y") * (invertY ? 1 : -1));

var mouseSensitivityFactor =
[Link]([Link]);

m_TargetCameraState.yaw += mouseMovement.x *
mouseSensitivityFactor;
m_TargetCameraState.pitch += mouseMovement.y *
mouseSensitivityFactor;
}

// Translation
translation = GetInputTranslationDirection() * [Link];

// Speed up movement when shift key held


if ([Link]([Link]))
{
translation *= 10.0f;
}

// Modify movement by a boost factor (defined in Inspector and modified


in play mode through the mouse scroll wheel)
boost += [Link].y * 0.2f;
translation *= [Link](2.0f, boost);

#elif USE_INPUT_SYSTEM
// TODO: make the new input system work
#endif

m_TargetCameraState.Translate(translation);

// Framerate-independent interpolation
// Calculate the lerp amount, such that we get 99% of the way to our
target in the specified time
var positionLerpPct = 1f - [Link](([Link](1f - 0.99f) /
positionLerpTime) * [Link]);
var rotationLerpPct = 1f - [Link](([Link](1f - 0.99f) /
rotationLerpTime) * [Link]);
m_InterpolatingCameraState.LerpTowards(m_TargetCameraState,
positionLerpPct, rotationLerpPct);

m_InterpolatingCameraState.UpdateTransform(transform);
}
}

}#if ENABLE_INPUT_SYSTEM && ENABLE_INPUT_SYSTEM_PACKAGE


#define USE_INPUT_SYSTEM
using [Link];
using [Link];
#endif

using UnityEngine;

namespace UnityTemplateProjects
{
public class SimpleCameraController : MonoBehaviour
{
class CameraState
{
public float yaw;
public float pitch;
public float roll;
public float x;
public float y;
public float z;

public void SetFromTransform(Transform t)


{
pitch = [Link].x;
yaw = [Link].y;
roll = [Link].z;
x = [Link].x;
y = [Link].y;
z = [Link].z;
}

public void Translate(Vector3 translation)


{
Vector3 rotatedTranslation = [Link](pitch, yaw, roll) *
translation;

x += rotatedTranslation.x;
y += rotatedTranslation.y;
z += rotatedTranslation.z;
}

public void LerpTowards(CameraState target, float positionLerpPct,


float rotationLerpPct)
{
yaw = [Link](yaw, [Link], rotationLerpPct);
pitch = [Link](pitch, [Link], rotationLerpPct);
roll = [Link](roll, [Link], rotationLerpPct);

x = [Link](x, target.x, positionLerpPct);


y = [Link](y, target.y, positionLerpPct);
z = [Link](z, target.z, positionLerpPct);
}

public void UpdateTransform(Transform t)


{
[Link] = new Vector3(pitch, yaw, roll);
[Link] = new Vector3(x, y, z);
}
}

CameraState m_TargetCameraState = new CameraState();


CameraState m_InterpolatingCameraState = new CameraState();

[Header("Movement Settings")]
[Tooltip("Exponential boost factor on translation, controllable by mouse
wheel.")]
public float boost = 3.5f;

[Tooltip("Time it takes to interpolate camera position 99% of the way to


the target."), Range(0.001f, 1f)]
public float positionLerpTime = 0.2f;

[Header("Rotation Settings")]
[Tooltip("X = Change in mouse position.\nY = Multiplicative factor for
camera rotation.")]
public AnimationCurve mouseSensitivityCurve = new AnimationCurve(new
Keyframe(0f, 0.5f, 0f, 5f), new Keyframe(1f, 2.5f, 0f, 0f));

[Tooltip("Time it takes to interpolate camera rotation 99% of the way to


the target."), Range(0.001f, 1f)]
public float rotationLerpTime = 0.01f;

[Tooltip("Whether or not to invert our Y axis for mouse input to


rotation.")]
public bool invertY = false;

void OnEnable()
{
m_TargetCameraState.SetFromTransform(transform);
m_InterpolatingCameraState.SetFromTransform(transform);
}

Vector3 GetInputTranslationDirection()
{
Vector3 direction = new Vector3();
if ([Link](KeyCode.W))
{
direction += [Link];
}
if ([Link](KeyCode.S))
{
direction += [Link];
}
if ([Link](KeyCode.A))
{
direction += [Link];
}
if ([Link](KeyCode.D))
{
direction += [Link];
}
if ([Link](KeyCode.Q))
{
direction += [Link];
}
if ([Link](KeyCode.E))
{
direction += [Link];
}
return direction;
}

void Update()
{
Vector3 translation = [Link];

#if ENABLE_LEGACY_INPUT_MANAGER

// Exit Sample
if ([Link]([Link]))
{
[Link]();
#if UNITY_EDITOR
[Link] = false;
#endif
}
// Hide and lock cursor when right mouse button pressed
if ([Link](1))
{
[Link] = [Link];
}

// Unlock and show cursor when right mouse button released


if ([Link](1))
{
[Link] = true;
[Link] = [Link];
}

// Rotation
if ([Link](1))
{
var mouseMovement = new Vector2([Link]("Mouse X"),
[Link]("Mouse Y") * (invertY ? 1 : -1));

var mouseSensitivityFactor =
[Link]([Link]);

m_TargetCameraState.yaw += mouseMovement.x *
mouseSensitivityFactor;
m_TargetCameraState.pitch += mouseMovement.y *
mouseSensitivityFactor;
}

// Translation
translation = GetInputTranslationDirection() * [Link];

// Speed up movement when shift key held


if ([Link]([Link]))
{
translation *= 10.0f;
}

// Modify movement by a boost factor (defined in Inspector and modified


in play mode through the mouse scroll wheel)
boost += [Link].y * 0.2f;
translation *= [Link](2.0f, boost);

#elif USE_INPUT_SYSTEM
// TODO: make the new input system work
#endif

m_TargetCameraState.Translate(translation);

// Framerate-independent interpolation
// Calculate the lerp amount, such that we get 99% of the way to our
target in the specified time
var positionLerpPct = 1f - [Link](([Link](1f - 0.99f) /
positionLerpTime) * [Link]);
var rotationLerpPct = 1f - [Link](([Link](1f - 0.99f) /
rotationLerpTime) * [Link]);
m_InterpolatingCameraState.LerpTowards(m_TargetCameraState,
positionLerpPct, rotationLerpPct);

m_InterpolatingCameraState.UpdateTransform(transform);
}
}

}#if ENABLE_INPUT_SYSTEM && ENABLE_INPUT_SYSTEM_PACKAGE


#define USE_INPUT_SYSTEM
using [Link];
using [Link];
#endif

using UnityEngine;

namespace UnityTemplateProjects
{
public class SimpleCameraController : MonoBehaviour
{
class CameraState
{
public float yaw;
public float pitch;
public float roll;
public float x;
public float y;
public float z;

public void SetFromTransform(Transform t)


{
pitch = [Link].x;
yaw = [Link].y;
roll = [Link].z;
x = [Link].x;
y = [Link].y;
z = [Link].z;
}
public void Translate(Vector3 translation)
{
Vector3 rotatedTranslation = [Link](pitch, yaw, roll) *
translation;

x += rotatedTranslation.x;
y += rotatedTranslation.y;
z += rotatedTranslation.z;
}

public void LerpTowards(CameraState target, float positionLerpPct,


float rotationLerpPct)
{
yaw = [Link](yaw, [Link], rotationLerpPct);
pitch = [Link](pitch, [Link], rotationLerpPct);
roll = [Link](roll, [Link], rotationLerpPct);

x = [Link](x, target.x, positionLerpPct);


y = [Link](y, target.y, positionLerpPct);
z = [Link](z, target.z, positionLerpPct);
}

public void UpdateTransform(Transform t)


{
[Link] = new Vector3(pitch, yaw, roll);
[Link] = new Vector3(x, y, z);
}
}

CameraState m_TargetCameraState = new CameraState();


CameraState m_InterpolatingCameraState = new CameraState();

[Header("Movement Settings")]
[Tooltip("Exponential boost factor on translation, controllable by mouse
wheel.")]
public float boost = 3.5f;

[Tooltip("Time it takes to interpolate camera position 99% of the way to


the target."), Range(0.001f, 1f)]
public float positionLerpTime = 0.2f;

[Header("Rotation Settings")]
[Tooltip("X = Change in mouse position.\nY = Multiplicative factor for
camera rotation.")]
public AnimationCurve mouseSensitivityCurve = new AnimationCurve(new
Keyframe(0f, 0.5f, 0f, 5f), new Keyframe(1f, 2.5f, 0f, 0f));

[Tooltip("Time it takes to interpolate camera rotation 99% of the way to


the target."), Range(0.001f, 1f)]
public float rotationLerpTime = 0.01f;

[Tooltip("Whether or not to invert our Y axis for mouse input to


rotation.")]
public bool invertY = false;

void OnEnable()
{
m_TargetCameraState.SetFromTransform(transform);
m_InterpolatingCameraState.SetFromTransform(transform);
}

Vector3 GetInputTranslationDirection()
{
Vector3 direction = new Vector3();
if ([Link](KeyCode.W))
{
direction += [Link];
}
if ([Link](KeyCode.S))
{
direction += [Link];
}
if ([Link](KeyCode.A))
{
direction += [Link];
}
if ([Link](KeyCode.D))
{
direction += [Link];
}
if ([Link](KeyCode.Q))
{
direction += [Link];
}
if ([Link](KeyCode.E))
{
direction += [Link];
}
return direction;
}

void Update()
{
Vector3 translation = [Link];

#if ENABLE_LEGACY_INPUT_MANAGER

// Exit Sample
if ([Link]([Link]))
{
[Link]();
#if UNITY_EDITOR
[Link] = false;
#endif
}
// Hide and lock cursor when right mouse button pressed
if ([Link](1))
{
[Link] = [Link];
}

// Unlock and show cursor when right mouse button released


if ([Link](1))
{
[Link] = true;
[Link] = [Link];
}
// Rotation
if ([Link](1))
{
var mouseMovement = new Vector2([Link]("Mouse X"),
[Link]("Mouse Y") * (invertY ? 1 : -1));

var mouseSensitivityFactor =
[Link]([Link]);

m_TargetCameraState.yaw += mouseMovement.x *
mouseSensitivityFactor;
m_TargetCameraState.pitch += mouseMovement.y *
mouseSensitivityFactor;
}

// Translation
translation = GetInputTranslationDirection() * [Link];

// Speed up movement when shift key held


if ([Link]([Link]))
{
translation *= 10.0f;
}

// Modify movement by a boost factor (defined in Inspector and modified


in play mode through the mouse scroll wheel)
boost += [Link].y * 0.2f;
translation *= [Link](2.0f, boost);

#elif USE_INPUT_SYSTEM
// TODO: make the new input system work
#endif

m_TargetCameraState.Translate(translation);

// Framerate-independent interpolation
// Calculate the lerp amount, such that we get 99% of the way to our
target in the specified time
var positionLerpPct = 1f - [Link](([Link](1f - 0.99f) /
positionLerpTime) * [Link]);
var rotationLerpPct = 1f - [Link](([Link](1f - 0.99f) /
rotationLerpTime) * [Link]);
m_InterpolatingCameraState.LerpTowards(m_TargetCameraState,
positionLerpPct, rotationLerpPct);

m_InterpolatingCameraState.UpdateTransform(transform);
}
}

}#if ENABLE_INPUT_SYSTEM && ENABLE_INPUT_SYSTEM_PACKAGE


#define USE_INPUT_SYSTEM
using [Link];
using [Link];
#endif

using UnityEngine;

namespace UnityTemplateProjects
{
public class SimpleCameraController : MonoBehaviour
{
class CameraState
{
public float yaw;
public float pitch;
public float roll;
public float x;
public float y;
public float z;

public void SetFromTransform(Transform t)


{
pitch = [Link].x;
yaw = [Link].y;
roll = [Link].z;
x = [Link].x;
y = [Link].y;
z = [Link].z;
}

public void Translate(Vector3 translation)


{
Vector3 rotatedTranslation = [Link](pitch, yaw, roll) *
translation;

x += rotatedTranslation.x;
y += rotatedTranslation.y;
z += rotatedTranslation.z;
}

public void LerpTowards(CameraState target, float positionLerpPct,


float rotationLerpPct)
{
yaw = [Link](yaw, [Link], rotationLerpPct);
pitch = [Link](pitch, [Link], rotationLerpPct);
roll = [Link](roll, [Link], rotationLerpPct);

x = [Link](x, target.x, positionLerpPct);


y = [Link](y, target.y, positionLerpPct);
z = [Link](z, target.z, positionLerpPct);
}

public void UpdateTransform(Transform t)


{
[Link] = new Vector3(pitch, yaw, roll);
[Link] = new Vector3(x, y, z);
}
}

CameraState m_TargetCameraState = new CameraState();


CameraState m_InterpolatingCameraState = new CameraState();

[Header("Movement Settings")]
[Tooltip("Exponential boost factor on translation, controllable by mouse
wheel.")]
public float boost = 3.5f;
[Tooltip("Time it takes to interpolate camera position 99% of the way to
the target."), Range(0.001f, 1f)]
public float positionLerpTime = 0.2f;

[Header("Rotation Settings")]
[Tooltip("X = Change in mouse position.\nY = Multiplicative factor for
camera rotation.")]
public AnimationCurve mouseSensitivityCurve = new AnimationCurve(new
Keyframe(0f, 0.5f, 0f, 5f), new Keyframe(1f, 2.5f, 0f, 0f));

[Tooltip("Time it takes to interpolate camera rotation 99% of the way to


the target."), Range(0.001f, 1f)]
public float rotationLerpTime = 0.01f;

[Tooltip("Whether or not to invert our Y axis for mouse input to


rotation.")]
public bool invertY = false;

void OnEnable()
{
m_TargetCameraState.SetFromTransform(transform);
m_InterpolatingCameraState.SetFromTransform(transform);
}

Vector3 GetInputTranslationDirection()
{
Vector3 direction = new Vector3();
if ([Link](KeyCode.W))
{
direction += [Link];
}
if ([Link](KeyCode.S))
{
direction += [Link];
}
if ([Link](KeyCode.A))
{
direction += [Link];
}
if ([Link](KeyCode.D))
{
direction += [Link];
}
if ([Link](KeyCode.Q))
{
direction += [Link];
}
if ([Link](KeyCode.E))
{
direction += [Link];
}
return direction;
}

void Update()
{
Vector3 translation = [Link];

#if ENABLE_LEGACY_INPUT_MANAGER
// Exit Sample
if ([Link]([Link]))
{
[Link]();
#if UNITY_EDITOR
[Link] = false;
#endif
}
// Hide and lock cursor when right mouse button pressed
if ([Link](1))
{
[Link] = [Link];
}

// Unlock and show cursor when right mouse button released


if ([Link](1))
{
[Link] = true;
[Link] = [Link];
}

// Rotation
if ([Link](1))
{
var mouseMovement = new Vector2([Link]("Mouse X"),
[Link]("Mouse Y") * (invertY ? 1 : -1));

var mouseSensitivityFactor =
[Link]([Link]);

m_TargetCameraState.yaw += mouseMovement.x *
mouseSensitivityFactor;
m_TargetCameraState.pitch += mouseMovement.y *
mouseSensitivityFactor;
}

// Translation
translation = GetInputTranslationDirection() * [Link];

// Speed up movement when shift key held


if ([Link]([Link]))
{
translation *= 10.0f;
}

// Modify movement by a boost factor (defined in Inspector and modified


in play mode through the mouse scroll wheel)
boost += [Link].y * 0.2f;
translation *= [Link](2.0f, boost);

#elif USE_INPUT_SYSTEM
// TODO: make the new input system work
#endif

m_TargetCameraState.Translate(translation);

// Framerate-independent interpolation
// Calculate the lerp amount, such that we get 99% of the way to our
target in the specified time
var positionLerpPct = 1f - [Link](([Link](1f - 0.99f) /
positionLerpTime) * [Link]);
var rotationLerpPct = 1f - [Link](([Link](1f - 0.99f) /
rotationLerpTime) * [Link]);
m_InterpolatingCameraState.LerpTowards(m_TargetCameraState,
positionLerpPct, rotationLerpPct);

m_InterpolatingCameraState.UpdateTransform(transform);
}
}

}#if ENABLE_INPUT_SYSTEM && ENABLE_INPUT_SYSTEM_PACKAGE


#define USE_INPUT_SYSTEM
using [Link];
using [Link];
#endif

using UnityEngine;

namespace UnityTemplateProjects
{
public class SimpleCameraController : MonoBehaviour
{
class CameraState
{
public float yaw;
public float pitch;
public float roll;
public float x;
public float y;
public float z;

public void SetFromTransform(Transform t)


{
pitch = [Link].x;
yaw = [Link].y;
roll = [Link].z;
x = [Link].x;
y = [Link].y;
z = [Link].z;
}

public void Translate(Vector3 translation)


{
Vector3 rotatedTranslation = [Link](pitch, yaw, roll) *
translation;

x += rotatedTranslation.x;
y += rotatedTranslation.y;
z += rotatedTranslation.z;
}

public void LerpTowards(CameraState target, float positionLerpPct,


float rotationLerpPct)
{
yaw = [Link](yaw, [Link], rotationLerpPct);
pitch = [Link](pitch, [Link], rotationLerpPct);
roll = [Link](roll, [Link], rotationLerpPct);
x = [Link](x, target.x, positionLerpPct);
y = [Link](y, target.y, positionLerpPct);
z = [Link](z, target.z, positionLerpPct);
}

public void UpdateTransform(Transform t)


{
[Link] = new Vector3(pitch, yaw, roll);
[Link] = new Vector3(x, y, z);
}
}

CameraState m_TargetCameraState = new CameraState();


CameraState m_InterpolatingCameraState = new CameraState();

[Header("Movement Settings")]
[Tooltip("Exponential boost factor on translation, controllable by mouse
wheel.")]
public float boost = 3.5f;

[Tooltip("Time it takes to interpolate camera position 99% of the way to


the target."), Range(0.001f, 1f)]
public float positionLerpTime = 0.2f;

[Header("Rotation Settings")]
[Tooltip("X = Change in mouse position.\nY = Multiplicative factor for
camera rotation.")]
public AnimationCurve mouseSensitivityCurve = new AnimationCurve(new
Keyframe(0f, 0.5f, 0f, 5f), new Keyframe(1f, 2.5f, 0f, 0f));

[Tooltip("Time it takes to interpolate camera rotation 99% of the way to


the target."), Range(0.001f, 1f)]
public float rotationLerpTime = 0.01f;

[Tooltip("Whether or not to invert our Y axis for mouse input to


rotation.")]
public bool invertY = false;

void OnEnable()
{
m_TargetCameraState.SetFromTransform(transform);
m_InterpolatingCameraState.SetFromTransform(transform);
}

Vector3 GetInputTranslationDirection()
{
Vector3 direction = new Vector3();
if ([Link](KeyCode.W))
{
direction += [Link];
}
if ([Link](KeyCode.S))
{
direction += [Link];
}
if ([Link](KeyCode.A))
{
direction += [Link];
}
if ([Link](KeyCode.D))
{
direction += [Link];
}
if ([Link](KeyCode.Q))
{
direction += [Link];
}
if ([Link](KeyCode.E))
{
direction += [Link];
}
return direction;
}

void Update()
{
Vector3 translation = [Link];

#if ENABLE_LEGACY_INPUT_MANAGER

// Exit Sample
if ([Link]([Link]))
{
[Link]();
#if UNITY_EDITOR
[Link] = false;
#endif
}
// Hide and lock cursor when right mouse button pressed
if ([Link](1))
{
[Link] = [Link];
}

// Unlock and show cursor when right mouse button released


if ([Link](1))
{
[Link] = true;
[Link] = [Link];
}

// Rotation
if ([Link](1))
{
var mouseMovement = new Vector2([Link]("Mouse X"),
[Link]("Mouse Y") * (invertY ? 1 : -1));

var mouseSensitivityFactor =
[Link]([Link]);

m_TargetCameraState.yaw += mouseMovement.x *
mouseSensitivityFactor;
m_TargetCameraState.pitch += mouseMovement.y *
mouseSensitivityFactor;
}

// Translation
translation = GetInputTranslationDirection() * [Link];

// Speed up movement when shift key held


if ([Link]([Link]))
{
translation *= 10.0f;
}

// Modify movement by a boost factor (defined in Inspector and modified


in play mode through the mouse scroll wheel)
boost += [Link].y * 0.2f;
translation *= [Link](2.0f, boost);

#elif USE_INPUT_SYSTEM
// TODO: make the new input system work
#endif

m_TargetCameraState.Translate(translation);

// Framerate-independent interpolation
// Calculate the lerp amount, such that we get 99% of the way to our
target in the specified time
var positionLerpPct = 1f - [Link](([Link](1f - 0.99f) /
positionLerpTime) * [Link]);
var rotationLerpPct = 1f - [Link](([Link](1f - 0.99f) /
rotationLerpTime) * [Link]);
m_InterpolatingCameraState.LerpTowards(m_TargetCameraState,
positionLerpPct, rotationLerpPct);

m_InterpolatingCameraState.UpdateTransform(transform);
}
}

}#if ENABLE_INPUT_SYSTEM && ENABLE_INPUT_SYSTEM_PACKAGE


#define USE_INPUT_SYSTEM
using [Link];
using [Link];
#endif

using UnityEngine;

namespace UnityTemplateProjects
{
public class SimpleCameraController : MonoBehaviour
{
class CameraState
{
public float yaw;
public float pitch;
public float roll;
public float x;
public float y;
public float z;

public void SetFromTransform(Transform t)


{
pitch = [Link].x;
yaw = [Link].y;
roll = [Link].z;
x = [Link].x;
y = [Link].y;
z = [Link].z;
}

public void Translate(Vector3 translation)


{
Vector3 rotatedTranslation = [Link](pitch, yaw, roll) *
translation;

x += rotatedTranslation.x;
y += rotatedTranslation.y;
z += rotatedTranslation.z;
}

public void LerpTowards(CameraState target, float positionLerpPct,


float rotationLerpPct)
{
yaw = [Link](yaw, [Link], rotationLerpPct);
pitch = [Link](pitch, [Link], rotationLerpPct);
roll = [Link](roll, [Link], rotationLerpPct);

x = [Link](x, target.x, positionLerpPct);


y = [Link](y, target.y, positionLerpPct);
z = [Link](z, target.z, positionLerpPct);
}

public void UpdateTransform(Transform t)


{
[Link] = new Vector3(pitch, yaw, roll);
[Link] = new Vector3(x, y, z);
}
}

CameraState m_TargetCameraState = new CameraState();


CameraState m_InterpolatingCameraState = new CameraState();

[Header("Movement Settings")]
[Tooltip("Exponential boost factor on translation, controllable by mouse
wheel.")]
public float boost = 3.5f;

[Tooltip("Time it takes to interpolate camera position 99% of the way to


the target."), Range(0.001f, 1f)]
public float positionLerpTime = 0.2f;

[Header("Rotation Settings")]
[Tooltip("X = Change in mouse position.\nY = Multiplicative factor for
camera rotation.")]
public AnimationCurve mouseSensitivityCurve = new AnimationCurve(new
Keyframe(0f, 0.5f, 0f, 5f), new Keyframe(1f, 2.5f, 0f, 0f));

[Tooltip("Time it takes to interpolate camera rotation 99% of the way to


the target."), Range(0.001f, 1f)]
public float rotationLerpTime = 0.01f;

[Tooltip("Whether or not to invert our Y axis for mouse input to


rotation.")]
public bool invertY = false;
void OnEnable()
{
m_TargetCameraState.SetFromTransform(transform);
m_InterpolatingCameraState.SetFromTransform(transform);
}

Vector3 GetInputTranslationDirection()
{
Vector3 direction = new Vector3();
if ([Link](KeyCode.W))
{
direction += [Link];
}
if ([Link](KeyCode.S))
{
direction += [Link];
}
if ([Link](KeyCode.A))
{
direction += [Link];
}
if ([Link](KeyCode.D))
{
direction += [Link];
}
if ([Link](KeyCode.Q))
{
direction += [Link];
}
if ([Link](KeyCode.E))
{
direction += [Link];
}
return direction;
}

void Update()
{
Vector3 translation = [Link];

#if ENABLE_LEGACY_INPUT_MANAGER

// Exit Sample
if ([Link]([Link]))
{
[Link]();
#if UNITY_EDITOR
[Link] = false;
#endif
}
// Hide and lock cursor when right mouse button pressed
if ([Link](1))
{
[Link] = [Link];
}

// Unlock and show cursor when right mouse button released


if ([Link](1))
{
[Link] = true;
[Link] = [Link];
}

// Rotation
if ([Link](1))
{
var mouseMovement = new Vector2([Link]("Mouse X"),
[Link]("Mouse Y") * (invertY ? 1 : -1));

var mouseSensitivityFactor =
[Link]([Link]);

m_TargetCameraState.yaw += mouseMovement.x *
mouseSensitivityFactor;
m_TargetCameraState.pitch += mouseMovement.y *
mouseSensitivityFactor;
}

// Translation
translation = GetInputTranslationDirection() * [Link];

// Speed up movement when shift key held


if ([Link]([Link]))
{
translation *= 10.0f;
}

// Modify movement by a boost factor (defined in Inspector and modified


in play mode through the mouse scroll wheel)
boost += [Link].y * 0.2f;
translation *= [Link](2.0f, boost);

#elif USE_INPUT_SYSTEM
// TODO: make the new input system work
#endif

m_TargetCameraState.Translate(translation);

// Framerate-independent interpolation
// Calculate the lerp amount, such that we get 99% of the way to our
target in the specified time
var positionLerpPct = 1f - [Link](([Link](1f - 0.99f) /
positionLerpTime) * [Link]);
var rotationLerpPct = 1f - [Link](([Link](1f - 0.99f) /
rotationLerpTime) * [Link]);
m_InterpolatingCameraState.LerpTowards(m_TargetCameraState,
positionLerpPct, rotationLerpPct);

m_InterpolatingCameraState.UpdateTransform(transform);
}
}

}#if ENABLE_INPUT_SYSTEM && ENABLE_INPUT_SYSTEM_PACKAGE


#define USE_INPUT_SYSTEM
using [Link];
using [Link];
#endif
using UnityEngine;

namespace UnityTemplateProjects
{
public class SimpleCameraController : MonoBehaviour
{
class CameraState
{
public float yaw;
public float pitch;
public float roll;
public float x;
public float y;
public float z;

public void SetFromTransform(Transform t)


{
pitch = [Link].x;
yaw = [Link].y;
roll = [Link].z;
x = [Link].x;
y = [Link].y;
z = [Link].z;
}

public void Translate(Vector3 translation)


{
Vector3 rotatedTranslation = [Link](pitch, yaw, roll) *
translation;

x += rotatedTranslation.x;
y += rotatedTranslation.y;
z += rotatedTranslation.z;
}

public void LerpTowards(CameraState target, float positionLerpPct,


float rotationLerpPct)
{
yaw = [Link](yaw, [Link], rotationLerpPct);
pitch = [Link](pitch, [Link], rotationLerpPct);
roll = [Link](roll, [Link], rotationLerpPct);

x = [Link](x, target.x, positionLerpPct);


y = [Link](y, target.y, positionLerpPct);
z = [Link](z, target.z, positionLerpPct);
}

public void UpdateTransform(Transform t)


{
[Link] = new Vector3(pitch, yaw, roll);
[Link] = new Vector3(x, y, z);
}
}

CameraState m_TargetCameraState = new CameraState();


CameraState m_InterpolatingCameraState = new CameraState();

[Header("Movement Settings")]
[Tooltip("Exponential boost factor on translation, controllable by mouse
wheel.")]
public float boost = 3.5f;

[Tooltip("Time it takes to interpolate camera position 99% of the way to


the target."), Range(0.001f, 1f)]
public float positionLerpTime = 0.2f;

[Header("Rotation Settings")]
[Tooltip("X = Change in mouse position.\nY = Multiplicative factor for
camera rotation.")]
public AnimationCurve mouseSensitivityCurve = new AnimationCurve(new
Keyframe(0f, 0.5f, 0f, 5f), new Keyframe(1f, 2.5f, 0f, 0f));

[Tooltip("Time it takes to interpolate camera rotation 99% of the way to


the target."), Range(0.001f, 1f)]
public float rotationLerpTime = 0.01f;

[Tooltip("Whether or not to invert our Y axis for mouse input to


rotation.")]
public bool invertY = false;

void OnEnable()
{
m_TargetCameraState.SetFromTransform(transform);
m_InterpolatingCameraState.SetFromTransform(transform);
}

Vector3 GetInputTranslationDirection()
{
Vector3 direction = new Vector3();
if ([Link](KeyCode.W))
{
direction += [Link];
}
if ([Link](KeyCode.S))
{
direction += [Link];
}
if ([Link](KeyCode.A))
{
direction += [Link];
}
if ([Link](KeyCode.D))
{
direction += [Link];
}
if ([Link](KeyCode.Q))
{
direction += [Link];
}
if ([Link](KeyCode.E))
{
direction += [Link];
}
return direction;
}

void Update()
{
Vector3 translation = [Link];

#if ENABLE_LEGACY_INPUT_MANAGER

// Exit Sample
if ([Link]([Link]))
{
[Link]();
#if UNITY_EDITOR
[Link] = false;
#endif
}
// Hide and lock cursor when right mouse button pressed
if ([Link](1))
{
[Link] = [Link];
}

// Unlock and show cursor when right mouse button released


if ([Link](1))
{
[Link] = true;
[Link] = [Link];
}

// Rotation
if ([Link](1))
{
var mouseMovement = new Vector2([Link]("Mouse X"),
[Link]("Mouse Y") * (invertY ? 1 : -1));

var mouseSensitivityFactor =
[Link]([Link]);

m_TargetCameraState.yaw += mouseMovement.x *
mouseSensitivityFactor;
m_TargetCameraState.pitch += mouseMovement.y *
mouseSensitivityFactor;
}

// Translation
translation = GetInputTranslationDirection() * [Link];

// Speed up movement when shift key held


if ([Link]([Link]))
{
translation *= 10.0f;
}

// Modify movement by a boost factor (defined in Inspector and modified


in play mode through the mouse scroll wheel)
boost += [Link].y * 0.2f;
translation *= [Link](2.0f, boost);

#elif USE_INPUT_SYSTEM
// TODO: make the new input system work
#endif
m_TargetCameraState.Translate(translation);

// Framerate-independent interpolation
// Calculate the lerp amount, such that we get 99% of the way to our
target in the specified time
var positionLerpPct = 1f - [Link](([Link](1f - 0.99f) /
positionLerpTime) * [Link]);
var rotationLerpPct = 1f - [Link](([Link](1f - 0.99f) /
rotationLerpTime) * [Link]);
m_InterpolatingCameraState.LerpTowards(m_TargetCameraState,
positionLerpPct, rotationLerpPct);

m_InterpolatingCameraState.UpdateTransform(transform);
}
}

}#if ENABLE_INPUT_SYSTEM && ENABLE_INPUT_SYSTEM_PACKAGE


#using UnityEditor;
using UnityEngine;

[CustomEditor(typeof(WaveFunctionCollapse))]
public class WaveFunctionCollapseEditor : Editor
{
public override void OnInspectorGUI()
{
DrawDefaultInspector();

WaveFunctionCollapse waveFunctionCollapse = (WaveFunctionCollapse)target;


if ([Link]("Initialize Wave Function Collapse"))
{using UnityEditor;
using UnityEngine;

[CustomEditor(typeof(WaveFunctionCollapse))]
public class WaveFunctionCollapseEditor : Editor
{
public override void OnInspectorGUI()
{
DrawDefaultInspector();

WaveFunctionCollapse waveFunctionCollapse = (WaveFunctionCollapse)target;


if ([Link]("Initialize Wave Function Collapse"))
{
[Link]();
}
}
}

[Link]();
}
}
}
not to invert our Y axis for mouse input to rotation.")]
public bool invertY = false;

void OnEnable()
{
m_TargetCameraState.SetFromTransform(transform);
m_InterpolatingCameraState.SetFromTransform(transform);
}
Vector3 GetInputTranslationDirection()
{
Vector3 direction = new Vector3();
if ([Link](KeyCode.W))
{
direction += [Link];
}
if ([Link](KeyCode.S))
{
direction += [Link];
}
if ([Link](KeyCode.A))
{
direction += [Link];
}
if ([Link](KeyCode.D))
{
direction += [Link];
}
if ([Link](KeyCode.Q))
{
direction += [Link];
}
if ([Link](KeyCode.E))
{
direction += [Link];
}
return direction;
}

void Update()
{
Vector3 translation = [Link];

#if ENABLE_LEGACY_INPUT_MANAGER

// Exit Sample
if ([Link]([Link]))
{
[Link]();
#if UNITY_EDITOR
[Link] = false;
#endif
}
// Hide and lock cursor when right mouse button pressed
if ([Link](1))
{
[Link] = [Link];
}

// Unlock and show cursor when right mouse button released


if ([Link](1))
{
[Link] = true;
[Link] = [Link];
}

// Rotation
if ([Link](1))
{
var mouseMovement = new Vector2([Link]("Mouse X"),
[Link]("Mouse Y") * (invertY ? 1 : -1));

var mouseSensitivityFactor =
[Link]([Link]);

m_TargetCameraState.yaw += mouseMovement.x *
mouseSensitivityFactor;
m_TargetCameraState.pitch += mouseMovement.y *
mouseSensitivityFactor;
}

// Translation
translation = GetInputTranslationDirection() * [Link];

// Speed up movement when shift key held


if ([Link]([Link]))
{
translation *= 10.0f;
}

// Modify movement by a boost factor (defined in Inspector and modified


in play mode through the mouse scroll wheel)
boost += [Link].y * 0.2f;
translation *= [Link](2.0f, boost);

#elif USE_INPUT_SYSTEM
// TODO: make the new input system work
#endif

m_TargetCameraState.Translate(translation);

// Framerate-independent interpolation
// Calculate the lerp amount, such that we get 99% of the way to our
target in the specified time
var positionLerpPct = 1f - [Link](([Link](1f - 0.99f) /
positionLerpTime) * [Link]);
var rotationLerpPct = 1f - [Link](([Link](1f - 0.99f) /
rotationLerpTime) * [Link]);
m_InterpolatingCameraState.LerpTowards(m_TargetCameraState,
positionLerpPct, rotationLerpPct);

m_InterpolatingCameraState.UpdateTransform(transform);
}
}

}#if ENABLE_INPUT_SYSTEM && ENABLE_INPUT_SYSTEM_PACKAGE


#define USE_INPUT_SYSTEM
using [Link];
using [Link];
#endif

using UnityEngine;

namespace UnityTemplateProjects
{
public class SimpleCameraController : MonoBehaviour
{
class CameraState
{
public float yaw;
public float pitch;
public float roll;
public float x;
public float y;
public float z;

public void SetFromTransform(Transform t)


{
pitch = [Link].x;
yaw = [Link].y;
roll = [Link].z;
x = [Link].x;
y = [Link].y;
z = [Link].z;
}

public void Translate(Vector3 translation)


{
Vector3 rotatedTranslation = [Link](pitch, yaw, roll) *
translation;

x += rotatedTranslation.x;
y += rotatedTranslation.y;
z += rotatedTranslation.z;
}

public void LerpTowards(CameraState target, float positionLerpPct,


float rotationLerpPct)
{
yaw = [Link](yaw, [Link], rotationLerpPct);
pitch = [Link](pitch, [Link], rotationLerpPct);
roll = [Link](roll, [Link], rotationLerpPct);

x = [Link](x, target.x, positionLerpPct);


y = [Link](y, target.y, positionLerpPct);
z = [Link](z, target.z, positionLerpPct);
}

public void UpdateTransform(Transform t)


{
[Link] = new Vector3(pitch, yaw, roll);
[Link] = new Vector3(x, y, z);
}
}

CameraState m_TargetCameraState = new CameraState();


CameraState m_InterpolatingCameraState = new CameraState();

[Header("Movement Settings")]
[Tooltip("Exponential boost factor on translation, controllable by mouse
wheel.")]
public float boost = 3.5f;

[Tooltip("Time it takes to interpolate camera position 99% of the way to


the target."), Range(0.001f, 1f)]
public float positionLerpTime = 0.2f;

[Header("Rotation Settings")]
[Tooltip("X = Change in mouse position.\nY = Multiplicative factor for
camera rotation.")]
public AnimationCurve mouseSensitivityCurve = new AnimationCurve(new
Keyframe(0f, 0.5f, 0f, 5f), new Keyframe(1f, 2.5f, 0f, 0f));

[Tooltip("Time it takes to interpolate camera rotation 99% of the way to


the target."), Range(0.001f, 1f)]
public float rotationLerpTime = 0.01f;

[Tooltip("Whether or not to invert our Y axis for mouse input to


rotation.")]
public bool invertY = false;

void OnEnable()
{
m_TargetCameraState.SetFromTransform(transform);
m_InterpolatingCameraState.SetFromTransform(transform);
}

Vector3 GetInputTranslationDirection()
{
Vector3 direction = new Vector3();
if ([Link](KeyCode.W))
{
direction += [Link];
}
if ([Link](KeyCode.S))
{
direction += [Link];
}
if ([Link](KeyCode.A))
{
direction += [Link];
}
if ([Link](KeyCode.D))
{
direction += [Link];
}
if ([Link](KeyCode.Q))
{
direction += [Link];
}
if ([Link](KeyCode.E))
{
direction += [Link];
}
return direction;
}

void Update()
{
Vector3 translation = [Link];

#if ENABLE_LEGACY_INPUT_MANAGER

// Exit Sample
if ([Link]([Link]))
{
[Link]();
#if UNITY_EDITOR
[Link] = false;
#endif
}
// Hide and lock cursor when right mouse button pressed
if ([Link](1))
{
[Link] = [Link];
}

// Unlock and show cursor when right mouse button released


if ([Link](1))
{
[Link] = true;
[Link] = [Link];
}

// Rotation
if ([Link](1))
{
var mouseMovement = new Vector2([Link]("Mouse X"),
[Link]("Mouse Y") * (invertY ? 1 : -1));

var mouseSensitivityFactor =
[Link]([Link]);

m_TargetCameraState.yaw += mouseMovement.x *
mouseSensitivityFactor;
m_TargetCameraState.pitch += mouseMovement.y *
mouseSensitivityFactor;
}

// Translation
translation = GetInputTranslationDirection() * [Link];

// Speed up movement when shift key held


if ([Link]([Link]))
{
translation *= 10.0f;
}

// Modify movement by a boost factor (defined in Inspector and modified


in play mode through the mouse scroll wheel)
boost += [Link].y * 0.2f;
translation *= [Link](2.0f, boost);

#elif USE_INPUT_SYSTEM
// TODO: make the new input system work
#endif

m_TargetCameraState.Translate(translation);

// Framerate-independent interpolation
// Calculate the lerp amount, such that we get 99% of the way to our
target in the specified time
var positionLerpPct = 1f - [Link](([Link](1f - 0.99f) /
positionLerpTime) * [Link]);
var rotationLerpPct = 1f - [Link](([Link](1f - 0.99f) /
rotationLerpTime) * [Link]);
m_InterpolatingCameraState.LerpTowards(m_TargetCameraState,
positionLerpPct, rotationLerpPct);

m_InterpolatingCameraState.UpdateTransform(transform);
}
}

}#if ENABLE_INPUT_SYSTEM && ENABLE_INPUT_SYSTEM_PACKAGE


#define USE_INPUT_SYSTEM
using [Link];
using [Link];
#endif

using UnityEngine;

namespace UnityTemplateProjects
{
public class SimpleCameraController : MonoBehaviour
{
class CameraState
{
public float yaw;
public float pitch;
public float roll;
public float x;
public float y;
public float z;

public void SetFromTransform(Transform t)


{
pitch = [Link].x;
yaw = [Link].y;
roll = [Link].z;
x = [Link].x;
y = [Link].y;
z = [Link].z;
}

public void Translate(Vector3 translation)


{
Vector3 rotatedTranslation = [Link](pitch, yaw, roll) *
translation;

x += rotatedTranslation.x;
y += rotatedTranslation.y;
z += rotatedTranslation.z;
}

public void LerpTowards(CameraState target, float positionLerpPct,


float rotationLerpPct)
{
yaw = [Link](yaw, [Link], rotationLerpPct);
pitch = [Link](pitch, [Link], rotationLerpPct);
roll = [Link](roll, [Link], rotationLerpPct);

x = [Link](x, target.x, positionLerpPct);


y = [Link](y, target.y, positionLerpPct);
z = [Link](z, target.z, positionLerpPct);
}

public void UpdateTransform(Transform t)


{
[Link] = new Vector3(pitch, yaw, roll);
[Link] = new Vector3(x, y, z);
}
}

CameraState m_TargetCameraState = new CameraState();


CameraState m_InterpolatingCameraState = new CameraState();

[Header("Movement Settings")]
[Tooltip("Exponential boost factor on translation, controllable by mouse
wheel.")]
public float boost = 3.5f;

[Tooltip("Time it takes to interpolate camera position 99% of the way to


the target."), Range(0.001f, 1f)]
public float positionLerpTime = 0.2f;

[Header("Rotation Settings")]
[Tooltip("X = Change in mouse position.\nY = Multiplicative factor for
camera rotation.")]
public AnimationCurve mouseSensitivityCurve = new AnimationCurve(new
Keyframe(0f, 0.5f, 0f, 5f), new Keyframe(1f, 2.5f, 0f, 0f));

[Tooltip("Time it takes to interpolate camera rotation 99% of the way to


the target."), Range(0.001f, 1f)]
public float rotationLerpTime = 0.01f;

[Tooltip("Whether or not to invert our Y axis for mouse input to


rotation.")]
public bool invertY = false;

void OnEnable()
{
m_TargetCameraState.SetFromTransform(transform);
m_InterpolatingCameraState.SetFromTransform(transform);
}

Vector3 GetInputTranslationDirection()
{
Vector3 direction = new Vector3();
if ([Link](KeyCode.W))
{
direction += [Link];
}
if ([Link](KeyCode.S))
{
direction += [Link];
}
if ([Link](KeyCode.A))
{
direction += [Link];
}
if ([Link](KeyCode.D))
{
direction += [Link];
}
if ([Link](KeyCode.Q))
{
direction += [Link];
}
if ([Link](KeyCode.E))
{
direction += [Link];
}
return direction;
}

void Update()
{
Vector3 translation = [Link];

#if ENABLE_LEGACY_INPUT_MANAGER

// Exit Sample
if ([Link]([Link]))
{
[Link]();
#if UNITY_EDITOR
[Link] = false;
#endif
}
// Hide and lock cursor when right mouse button pressed
if ([Link](1))
{
[Link] = [Link];
}

// Unlock and show cursor when right mouse button released


if ([Link](1))
{
[Link] = true;
[Link] = [Link];
}

// Rotation
if ([Link](1))
{
var mouseMovement = new Vector2([Link]("Mouse X"),
[Link]("Mouse Y") * (invertY ? 1 : -1));

var mouseSensitivityFactor =
[Link]([Link]);

m_TargetCameraState.yaw += mouseMovement.x *
mouseSensitivityFactor;
m_TargetCameraState.pitch += mouseMovement.y *
mouseSensitivityFactor;
}

// Translation
translation = GetInputTranslationDirection() * [Link];
// Speed up movement when shift key held
if ([Link]([Link]))
{
translation *= 10.0f;
}

// Modify movement by a boost factor (defined in Inspector and modified


in play mode through the mouse scroll wheel)
boost += [Link].y * 0.2f;
translation *= [Link](2.0f, boost);

#elif USE_INPUT_SYSTEM
// TODO: make the new input system work
#endif

m_TargetCameraState.Translate(translation);

// Framerate-independent interpolation
// Calculate the lerp amount, such that we get 99% of the way to our
target in the specified time
var positionLerpPct = 1f - [Link](([Link](1f - 0.99f) /
positionLerpTime) * [Link]);
var rotationLerpPct = 1f - [Link](([Link](1f - 0.99f) /
rotationLerpTime) * [Link]);
m_InterpolatingCameraState.LerpTowards(m_TargetCameraState,
positionLerpPct, rotationLerpPct);

m_InterpolatingCameraState.UpdateTransform(transform);
}
}

}#if ENABLE_INPUT_SYSTEM && ENABLE_INPUT_SYSTEM_PACKAGE


#define USE_INPUT_SYSTEM
using [Link];
using [Link];
#endif

using UnityEngine;

namespace UnityTemplateProjects
{
public class SimpleCameraController : MonoBehaviour
{
class CameraState
{
public float yaw;
public float pitch;
public float roll;
public float x;
public float y;
public float z;

public void SetFromTransform(Transform t)


{
pitch = [Link].x;
yaw = [Link].y;
roll = [Link].z;
x = [Link].x;
y = [Link].y;
z = [Link].z;
}

public void Translate(Vector3 translation)


{
Vector3 rotatedTranslation = [Link](pitch, yaw, roll) *
translation;

x += rotatedTranslation.x;
y += rotatedTranslation.y;
z += rotatedTranslation.z;
}

public void LerpTowards(CameraState target, float positionLerpPct,


float rotationLerpPct)
{
yaw = [Link](yaw, [Link], rotationLerpPct);
pitch = [Link](pitch, [Link], rotationLerpPct);
roll = [Link](roll, [Link], rotationLerpPct);

x = [Link](x, target.x, positionLerpPct);


y = [Link](y, target.y, positionLerpPct);
z = [Link](z, target.z, positionLerpPct);
}

public void UpdateTransform(Transform t)


{
[Link] = new Vector3(pitch, yaw, roll);
[Link] = new Vector3(x, y, z);
}
}

CameraState m_TargetCameraState = new CameraState();


CameraState m_InterpolatingCameraState = new CameraState();

[Header("Movement Settings")]
[Tooltip("Exponential boost factor on translation, controllable by mouse
wheel.")]
public float boost = 3.5f;

[Tooltip("Time it takes to interpolate camera position 99% of the way to


the target."), Range(0.001f, 1f)]
public float positionLerpTime = 0.2f;

[Header("Rotation Settings")]
[Tooltip("X = Change in mouse position.\nY = Multiplicative factor for
camera rotation.")]
public AnimationCurve mouseSensitivityCurve = new AnimationCurve(new
Keyframe(0f, 0.5f, 0f, 5f), new Keyframe(1f, 2.5f, 0f, 0f));

[Tooltip("Time it takes to interpolate camera rotation 99% of the way to


the target."), Range(0.001f, 1f)]
public float rotationLerpTime = 0.01f;

[Tooltip("Whether or not to invert our Y axis for mouse input to


rotation.")]
public bool invertY = false;

void OnEnable()
{
m_TargetCameraState.SetFromTransform(transform);
m_InterpolatingCameraState.SetFromTransform(transform);
}

Vector3 GetInputTranslationDirection()
{
Vector3 direction = new Vector3();
if ([Link](KeyCode.W))
{
direction += [Link];
}
if ([Link](KeyCode.S))
{
direction += [Link];
}
if ([Link](KeyCode.A))
{
direction += [Link];
}
if ([Link](KeyCode.D))
{
direction += [Link];
}
if ([Link](KeyCode.Q))
{
direction += [Link];
}
if ([Link](KeyCode.E))
{
direction += [Link];
}
return direction;
}

void Update()
{
Vector3 translation = [Link];

#if ENABLE_LEGACY_INPUT_MANAGER

// Exit Sample
if ([Link]([Link]))
{
[Link]();
#if UNITY_EDITOR
[Link] = false;
#endif
}
// Hide and lock cursor when right mouse button pressed
if ([Link](1))
{
[Link] = [Link];
}

// Unlock and show cursor when right mouse button released


if ([Link](1))
{
[Link] = true;
[Link] = [Link];
}

// Rotation
if ([Link](1))
{
var mouseMovement = new Vector2([Link]("Mouse X"),
[Link]("Mouse Y") * (invertY ? 1 : -1));

var mouseSensitivityFactor =
[Link]([Link]);

m_TargetCameraState.yaw += mouseMovement.x *
mouseSensitivityFactor;
m_TargetCameraState.pitch += mouseMovement.y *
mouseSensitivityFactor;
}

// Translation
translation = GetInputTranslationDirection() * [Link];

// Speed up movement when shift key held


if ([Link]([Link]))
{
translation *= 10.0f;
}

// Modify movement by a boost factor (defined in Inspector and modified


in play mode through the mouse scroll wheel)
boost += [Link].y * 0.2f;
translation *= [Link](2.0f, boost);

#elif USE_INPUT_SYSTEM
// TODO: make the new input system work
#endif

m_TargetCameraState.Translate(translation);

// Framerate-independent interpolation
// Calculate the lerp amount, such that we get 99% of the way to our
target in the specified time
var positionLerpPct = 1f - [Link](([Link](1f - 0.99f) /
positionLerpTime) * [Link]);
var rotationLerpPct = 1f - [Link](([Link](1f - 0.99f) /
rotationLerpTime) * [Link]);
m_InterpolatingCameraState.LerpTowards(m_TargetCameraState,
positionLerpPct, rotationLerpPct);

m_InterpolatingCameraState.UpdateTransform(transform);
}
}

}#if ENABLE_INPUT_SYSTEM && ENABLE_INPUT_SYSTEM_PACKAGE


#define USE_INPUT_SYSTEM
using [Link];
using [Link];
#endif

using UnityEngine;
namespace UnityTemplateProjects
{
public class SimpleCameraController : MonoBehaviour
{
class CameraState
{
public float yaw;
public float pitch;
public float roll;
public float x;
public float y;
public float z;

public void SetFromTransform(Transform t)


{
pitch = [Link].x;
yaw = [Link].y;
roll = [Link].z;
x = [Link].x;
y = [Link].y;
z = [Link].z;
}

public void Translate(Vector3 translation)


{
Vector3 rotatedTranslation = [Link](pitch, yaw, roll) *
translation;

x += rotatedTranslation.x;
y += rotatedTranslation.y;
z += rotatedTranslation.z;
}

public void LerpTowards(CameraState target, float positionLerpPct,


float rotationLerpPct)
{
yaw = [Link](yaw, [Link], rotationLerpPct);
pitch = [Link](pitch, [Link], rotationLerpPct);
roll = [Link](roll, [Link], rotationLerpPct);

x = [Link](x, target.x, positionLerpPct);


y = [Link](y, target.y, positionLerpPct);
z = [Link](z, target.z, positionLerpPct);
}

public void UpdateTransform(Transform t)


{
[Link] = new Vector3(pitch, yaw, roll);
[Link] = new Vector3(x, y, z);
}
}

CameraState m_TargetCameraState = new CameraState();


CameraState m_InterpolatingCameraState = new CameraState();

[Header("Movement Settings")]
[Tooltip("Exponential boost factor on translation, controllable by mouse
wheel.")]
public float boost = 3.5f;

[Tooltip("Time it takes to interpolate camera position 99% of the way to


the target."), Range(0.001f, 1f)]
public float positionLerpTime = 0.2f;

[Header("Rotation Settings")]
[Tooltip("X = Change in mouse position.\nY = Multiplicative factor for
camera rotation.")]
public AnimationCurve mouseSensitivityCurve = new AnimationCurve(new
Keyframe(0f, 0.5f, 0f, 5f), new Keyframe(1f, 2.5f, 0f, 0f));

[Tooltip("Time it takes to interpolate camera rotation 99% of the way to


the target."), Range(0.001f, 1f)]
public float rotationLerpTime = 0.01f;

[Tooltip("Whether or not to invert our Y axis for mouse input to


rotation.")]
public bool invertY = false;

void OnEnable()
{
m_TargetCameraState.SetFromTransform(transform);
m_InterpolatingCameraState.SetFromTransform(transform);
}

Vector3 GetInputTranslationDirection()
{
Vector3 direction = new Vector3();
if ([Link](KeyCode.W))
{
direction += [Link];
}
if ([Link](KeyCode.S))
{
direction += [Link];
}
if ([Link](KeyCode.A))
{
direction += [Link];
}
if ([Link](KeyCode.D))
{
direction += [Link];
}
if ([Link](KeyCode.Q))
{
direction += [Link];
}
if ([Link](KeyCode.E))
{
direction += [Link];
}
return direction;
}

void Update()
{
Vector3 translation = [Link];
#if ENABLE_LEGACY_INPUT_MANAGER

// Exit Sample
if ([Link]([Link]))
{
[Link]();
#if UNITY_EDITOR
[Link] = false;
#endif
}
// Hide and lock cursor when right mouse button pressed
if ([Link](1))
{
[Link] = [Link];
}

// Unlock and show cursor when right mouse button released


if ([Link](1))
{
[Link] = true;
[Link] = [Link];
}

// Rotation
if ([Link](1))
{
var mouseMovement = new Vector2([Link]("Mouse X"),
[Link]("Mouse Y") * (invertY ? 1 : -1));

var mouseSensitivityFactor =
[Link]([Link]);

m_TargetCameraState.yaw += mouseMovement.x *
mouseSensitivityFactor;
m_TargetCameraState.pitch += mouseMovement.y *
mouseSensitivityFactor;
}

// Translation
translation = GetInputTranslationDirection() * [Link];

// Speed up movement when shift key held


if ([Link]([Link]))
{
translation *= 10.0f;
}

// Modify movement by a boost factor (defined in Inspector and modified


in play mode through the mouse scroll wheel)
boost += [Link].y * 0.2f;
translation *= [Link](2.0f, boost);

#elif USE_INPUT_SYSTEM
// TODO: make the new input system work
#endif

m_TargetCameraState.Translate(translation);
// Framerate-independent interpolation
// Calculate the lerp amount, such that we get 99% of the way to our
target in the specified time
var positionLerpPct = 1f - [Link](([Link](1f - 0.99f) /
positionLerpTime) * [Link]);
var rotationLerpPct = 1f - [Link](([Link](1f - 0.99f) /
rotationLerpTime) * [Link]);
m_InterpolatingCameraState.LerpTowards(m_TargetCameraState,
positionLerpPct, rotationLerpPct);

m_InterpolatingCameraState.UpdateTransform(transform);
}
}

}#if ENABLE_INPUT_SYSTEM && ENABLE_INPUT_SYSTEM_PACKAGE


#define USE_INPUT_SYSTEM
using [Link];
using [Link];
#endif

using UnityEngine;

namespace UnityTemplateProjects
{
public class SimpleCameraController : MonoBehaviour
{
class CameraState
{
public float yaw;
public float pitch;
public float roll;
public float x;
public float y;
public float z;

public void SetFromTransform(Transform t)


{
pitch = [Link].x;
yaw = [Link].y;
roll = [Link].z;
x = [Link].x;
y = [Link].y;
z = [Link].z;
}

public void Translate(Vector3 translation)


{
Vector3 rotatedTranslation = [Link](pitch, yaw, roll) *
translation;

x += rotatedTranslation.x;
y += rotatedTranslation.y;
z += rotatedTranslation.z;
}

public void LerpTowards(CameraState target, float positionLerpPct,


float rotationLerpPct)
{
yaw = [Link](yaw, [Link], rotationLerpPct);
pitch = [Link](pitch, [Link], rotationLerpPct);
roll = [Link](roll, [Link], rotationLerpPct);

x = [Link](x, target.x, positionLerpPct);


y = [Link](y, target.y, positionLerpPct);
z = [Link](z, target.z, positionLerpPct);
}

public void UpdateTransform(Transform t)


{
[Link] = new Vector3(pitch, yaw, roll);
[Link] = new Vector3(x, y, z);
}
}

CameraState m_TargetCameraState = new CameraState();


CameraState m_InterpolatingCameraState = new CameraState();

[Header("Movement Settings")]
[Tooltip("Exponential boost factor on translation, controllable by mouse
wheel.")]
public float boost = 3.5f;

[Tooltip("Time it takes to interpolate camera position 99% of the way to


the target."), Range(0.001f, 1f)]
public float positionLerpTime = 0.2f;

[Header("Rotation Settings")]
[Tooltip("X = Change in mouse position.\nY = Multiplicative factor for
camera rotation.")]
public AnimationCurve mouseSensitivityCurve = new AnimationCurve(new
Keyframe(0f, 0.5f, 0f, 5f), new Keyframe(1f, 2.5f, 0f, 0f));

[Tooltip("Time it takes to interpolate camera rotation 99% of the way to


the target."), Range(0.001f, 1f)]
public float rotationLerpTime = 0.01f;

[Tooltip("Whether or not to invert our Y axis for mouse input to


rotation.")]
public bool invertY = false;

void OnEnable()
{
m_TargetCameraState.SetFromTransform(transform);
m_InterpolatingCameraState.SetFromTransform(transform);
}

Vector3 GetInputTranslationDirection()
{
Vector3 direction = new Vector3();
if ([Link](KeyCode.W))
{
direction += [Link];
}
if ([Link](KeyCode.S))
{
direction += [Link];
}
if ([Link](KeyCode.A))
{
direction += [Link];
}
if ([Link](KeyCode.D))
{
direction += [Link];
}
if ([Link](KeyCode.Q))
{
direction += [Link];
}
if ([Link](KeyCode.E))
{
direction += [Link];
}
return direction;
}

void Update()
{
Vector3 translation = [Link];

#if ENABLE_LEGACY_INPUT_MANAGER

// Exit Sample
if ([Link]([Link]))
{
[Link]();
#if UNITY_EDITOR
[Link] = false;
#endif
}
// Hide and lock cursor when right mouse button pressed
if ([Link](1))
{
[Link] = [Link];
}

// Unlock and show cursor when right mouse button released


if ([Link](1))
{
[Link] = true;
[Link] = [Link];
}

// Rotation
if ([Link](1))
{
var mouseMovement = new Vector2([Link]("Mouse X"),
[Link]("Mouse Y") * (invertY ? 1 : -1));

var mouseSensitivityFactor =
[Link]([Link]);

m_TargetCameraState.yaw += mouseMovement.x *
mouseSensitivityFactor;
m_TargetCameraState.pitch += mouseMovement.y *
mouseSensitivityFactor;
}
// Translation
translation = GetInputTranslationDirection() * [Link];

// Speed up movement when shift key held


if ([Link]([Link]))
{
translation *= 10.0f;
}

// Modify movement by a boost factor (defined in Inspector and modified


in play mode through the mouse scroll wheel)
boost += [Link].y * 0.2f;
translation *= [Link](2.0f, boost);

#elif USE_INPUT_SYSTEM
// TODO: make the new input system work
#endif

m_TargetCameraState.Translate(translation);

// Framerate-independent interpolation
// Calculate the lerp amount, such that we get 99% of the way to our
target in the specified time
var positionLerpPct = 1f - [Link](([Link](1f - 0.99f) /
positionLerpTime) * [Link]);
var rotationLerpPct = 1f - [Link](([Link](1f - 0.99f) /
rotationLerpTime) * [Link]);
m_InterpolatingCameraState.LerpTowards(m_TargetCameraState,
positionLerpPct, rotationLerpPct);

m_InterpolatingCameraState.UpdateTransform(transform);
}
}

}#if ENABLE_INPUT_SYSTEM && ENABLE_INPUT_SYSTEM_PACKAGE


#define USE_INPUT_SYSTEM
using [Link];
using [Link];
#endif

using UnityEngine;

namespace UnityTemplateProjects
{
public class SimpleCameraController : MonoBehaviour
{
class CameraState
{
public float yaw;
public float pitch;
public float roll;
public float x;
public float y;
public float z;

public void SetFromTransform(Transform t)


{
pitch = [Link].x;
yaw = [Link].y;
roll = [Link].z;
x = [Link].x;
y = [Link].y;
z = [Link].z;
}

public void Translate(Vector3 translation)


{
Vector3 rotatedTranslation = [Link](pitch, yaw, roll) *
translation;

x += rotatedTranslation.x;
y += rotatedTranslation.y;
z += rotatedTranslation.z;
}

public void LerpTowards(CameraState target, float positionLerpPct,


float rotationLerpPct)
{
yaw = [Link](yaw, [Link], rotationLerpPct);
pitch = [Link](pitch, [Link], rotationLerpPct);
roll = [Link](roll, [Link], rotationLerpPct);

x = [Link](x, target.x, positionLerpPct);


y = [Link](y, target.y, positionLerpPct);
z = [Link](z, target.z, positionLerpPct);
}

public void UpdateTransform(Transform t)


{
[Link] = new Vector3(pitch, yaw, roll);
[Link] = new Vector3(x, y, z);
}
}

CameraState m_TargetCameraState = new CameraState();


CameraState m_InterpolatingCameraState = new CameraState();

[Header("Movement Settings")]
[Tooltip("Exponential boost factor on translation, controllable by mouse
wheel.")]
public float boost = 3.5f;

[Tooltip("Time it takes to interpolate camera position 99% of the way to


the target."), Range(0.001f, 1f)]
public float positionLerpTime = 0.2f;

[Header("Rotation Settings")]
[Tooltip("X = Change in mouse position.\nY = Multiplicative factor for
camera rotation.")]
public AnimationCurve mouseSensitivityCurve = new AnimationCurve(new
Keyframe(0f, 0.5f, 0f, 5f), new Keyframe(1f, 2.5f, 0f, 0f));

[Tooltip("Time it takes to interpolate camera rotation 99% of the way to


the target."), Range(0.001f, 1f)]
public float rotationLerpTime = 0.01f;

[Tooltip("Whether or not to invert our Y axis for mouse input to


rotation.")]
public bool invertY = false;

void OnEnable()
{
m_TargetCameraState.SetFromTransform(transform);
m_InterpolatingCameraState.SetFromTransform(transform);
}

Vector3 GetInputTranslationDirection()
{
Vector3 direction = new Vector3();
if ([Link](KeyCode.W))
{
direction += [Link];
}
if ([Link](KeyCode.S))
{
direction += [Link];
}
if ([Link](KeyCode.A))
{
direction += [Link];
}
if ([Link](KeyCode.D))
{
direction += [Link];
}
if ([Link](KeyCode.Q))
{
direction += [Link];
}
if ([Link](KeyCode.E))
{
direction += [Link];
}
return direction;
}

void Update()
{
Vector3 translation = [Link];

#if ENABLE_LEGACY_INPUT_MANAGER

// Exit Sample
if ([Link]([Link]))
{
[Link]();
#if UNITY_EDITOR
[Link] = false;
#endif
}
// Hide and lock cursor when right mouse button pressed
if ([Link](1))
{
[Link] = [Link];
}
// Unlock and show cursor when right mouse button released
if ([Link](1))
{
[Link] = true;
[Link] = [Link];
}

// Rotation
if ([Link](1))
{
var mouseMovement = new Vector2([Link]("Mouse X"),
[Link]("Mouse Y") * (invertY ? 1 : -1));

var mouseSensitivityFactor =
[Link]([Link]);

m_TargetCameraState.yaw += mouseMovement.x *
mouseSensitivityFactor;
m_TargetCameraState.pitch += mouseMovement.y *
mouseSensitivityFactor;
}

// Translation
translation = GetInputTranslationDirection() * [Link];

// Speed up movement when shift key held


if ([Link]([Link]))
{
translation *= 10.0f;
}

// Modify movement by a boost factor (defined in Inspector and modified


in play mode through the mouse scroll wheel)
boost += [Link].y * 0.2f;
translation *= [Link](2.0f, boost);

#elif USE_INPUT_SYSTEM
// TODO: make the new input system work
#endif

m_TargetCameraState.Translate(translation);

// Framerate-independent interpolation
// Calculate the lerp amount, such that we get 99% of the way to our
target in the specified time
var positionLerpPct = 1f - [Link](([Link](1f - 0.99f) /
positionLerpTime) * [Link]);
var rotationLerpPct = 1f - [Link](([Link](1f - 0.99f) /
rotationLerpTime) * [Link]);
m_InterpolatingCameraState.LerpTowards(m_TargetCameraState,
positionLerpPct, rotationLerpPct);

m_InterpolatingCameraState.UpdateTransform(transform);
}
}

You might also like