Skip to content

Instantly share code, notes, and snippets.

@unitycoder
Created February 6, 2024 09:47
Show Gist options
  • Select an option

  • Save unitycoder/1a13f341bdedf03dd15e079033347555 to your computer and use it in GitHub Desktop.

Select an option

Save unitycoder/1a13f341bdedf03dd15e079033347555 to your computer and use it in GitHub Desktop.
Unity Limit Diagonal Speed (Horizontal, Vertical)
h = Input.GetAxisRaw(horizontalAxis) * walkSpeed * Time.deltaTime;
v = Input.GetAxisRaw(verticalAxis) * walkSpeed * Time.deltaTime;
if (h != 0 && v != 0)
{
h *= 0.7f;
v *= 0.7f;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment