Skip to content

Instantly share code, notes, and snippets.

@Streamweaver
Created February 7, 2020 04:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Streamweaver/ba88276fdc0d7d5330bbaadc07ee4bf6 to your computer and use it in GitHub Desktop.
Save Streamweaver/ba88276fdc0d7d5330bbaadc07ee4bf6 to your computer and use it in GitHub Desktop.
A simple set of static utilities I'm building up during Unity .
using UnityEngine;
namespace Streamweaver.Util
{
public static class StaticUtils
{
public static Vector3 GetRandomDir2D()
{
return new Vector3(Random.Range(-1f, 1f), Random.Range(-1f, 1f), 0).normalized;
}
public static Vector3 GetVectorFromAngle(int angle)
{
float angleRad = angle * Mathf.Deg2Rad;
return new Vector3(Mathf.Cos(angleRad), Mathf.Sin(angleRad));
}
public static Vector3 GetVectorFromAngle(float angle)
{
float angleRad = angle * Mathf.Deg2Rad;
return new Vector3(Mathf.Cos(angleRad), Mathf.Sin(angleRad));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment