Answers for "how to check if the distance between to gameobjects has an object between them unity 2d"

C#
12

unity get distance between two objects

// Vector3.Distance is the same as (a-b).magnitude

float distance = Vector3.Distance(a.transform.position, b.transform.position);
Posted by: Guest on November-29-2020
4

check distance to gameobject

/// <summary>
/// Return distance between two points
/// </summary>
/// <param name="target"></param>
/// <param name="startPos"></param>
/// <returns></returns>
public float CheckDistanceTwoPoints(Vector3 target, Vector3 startPos)
{
	return Vector3.Distance(target, startPos);
}
Posted by: Guest on May-03-2020

Code answers related to "how to check if the distance between to gameobjects has an object between them unity 2d"

C# Answers by Framework

Browse Popular Code Answers by Language