Skip to content

Instantly share code, notes, and snippets.

@MysticFragilist
Last active May 31, 2020 17:52
Show Gist options
  • Save MysticFragilist/026cb8da5db99ad49ee9932871ec105a to your computer and use it in GitHub Desktop.
Save MysticFragilist/026cb8da5db99ad49ee9932871ec105a to your computer and use it in GitHub Desktop.
A sample of a Game Manager script to embed in Medium
// Update the look movement each time the event is trigger
public void OnLook(InputAction.CallbackContext context)
{
//Normalize the vector to have an uniform vector in whichever form it came from (I.E Gamepad, mouse, etc)
Vector2 lookMovement = context.ReadValue<Vector2>().normalized;
lookMovement.y = InvertY ? -lookMovement.y : lookMovement.y;
// This is because X axis is only contains between -180 and 180 instead of 0 and 1 like the Y axis
lookMovement.x = lookMovement.x * 180f;
//Ajust axis values using look speed and Time.deltaTime so the look doesn't go faster if there is more FPS
_freeLookComponent.m_XAxis.Value += lookMovement.x * LookSpeed * Time.deltaTime;
_freeLookComponent.m_YAxis.Value += lookMovement.y * LookSpeed * Time.deltaTime;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment