Last active
May 31, 2020 17:52
-
-
Save MysticFragilist/026cb8da5db99ad49ee9932871ec105a to your computer and use it in GitHub Desktop.
A sample of a Game Manager script to embed in Medium
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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