Skip to content

Instantly share code, notes, and snippets.

@ashblue
Created October 6, 2015 22:42
Show Gist options
  • Save ashblue/faf65a38324976de8586 to your computer and use it in GitHub Desktop.
Save ashblue/faf65a38324976de8586 to your computer and use it in GitHub Desktop.
Vector3 extension class
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