mirror of
https://github.com/nothke/quality-control.git
synced 2025-08-08 23:03:43 +00:00
Working magnet and crane AI
This commit is contained in:
21
Assets/Scripts/Utils/DistanceExtension.cs
Normal file
21
Assets/Scripts/Utils/DistanceExtension.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public static class DistanceExtension
|
||||
{
|
||||
public static Vector2 Planar(this Vector3 vector)
|
||||
{
|
||||
return new Vector2(vector.x, vector.z);
|
||||
}
|
||||
|
||||
public static bool IsCloseTo(this Component c1, Component c2, float range = 1f)
|
||||
{
|
||||
return Vector3.Distance(c1.transform.position, c2.transform.position) < range;
|
||||
}
|
||||
|
||||
public static bool IsCloseToPlanar(this Component c1, Component c2, float range = 1f)
|
||||
{
|
||||
return Vector2.Distance(c1.transform.position.Planar(), c2.transform.position.Planar()) < range;
|
||||
}
|
||||
}
|
11
Assets/Scripts/Utils/DistanceExtension.cs.meta
Normal file
11
Assets/Scripts/Utils/DistanceExtension.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0288cadfdf5e82f4791af67e23c3d29d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user