Created
October 6, 2015 22:42
-
-
Save ashblue/faf65a38324976de8586 to your computer and use it in GitHub Desktop.
Vector3 extension class
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
using UnityEngine; | |
using System.Collections; | |
static public class Vector3Ext { | |
/// <summary> | |
/// Gives absolute distance instead of returning a negative value. | |
/// </summary> | |
/// <returns>The all.</returns> | |
/// <param name="pos1">Pos1.</param> | |
/// <param name="pos2">Pos2.</param> | |
static public Vector3 DistanceAll (Vector3 pos1, Vector3 pos2) { | |
Vector3 dist = pos1 - pos2; | |
dist.x = Mathf.Abs(dist.x); | |
dist.y = Mathf.Abs(dist.y); | |
dist.z = Mathf.Abs(dist.z); | |
return dist; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment