Skip to content

Instantly share code, notes, and snippets.

@webthingee
Last active April 17, 2019 21:55
Show Gist options
  • Save webthingee/f2815649e85d3b7915ea7dabd4563f50 to your computer and use it in GitHub Desktop.
Save webthingee/f2815649e85d3b7915ea7dabd4563f50 to your computer and use it in GitHub Desktop.
Quick List
Collider2D[] hits = Physics2D.OverlapCircleAll(transform.position, rangeRadius, masksToTarget);
if (hits.Length < 1)
{
myTarget = null;
myTargetDirection = Vector2.down;
}
float closest = Mathf.Infinity;
foreach (Collider2D hit in hits)
{
float distance = Vector2.Distance(transform.position, hit.transform.position);
if (distance < closest)
{
closest = distance;
myTarget = hit.gameObject;
myTargetDirection = (hit.transform.position - transform.position).normalized;
}
}
[CustomEditor(typeof(ActionTile))]
public class ActionTileEditor : Editor
{
public override void OnInspectorGUI()
{
DrawDefaultInspector();
ActionTile m = (ActionTile) target;
if (GUILayout.Button("Set Initial Stats"))
{
m.SetInitialStats();
}
}
}
return Camera.main.ViewportToWorldPoint(new Vector2(Random.value, Random.value));
private void Awake()
{
if (visualZone != null) return;
UnityEditor.EditorApplication.isPlaying = false;
Debug.LogError("Assign the " + visualZone.name + " in the inspector before resuming");
}
myTargetDirection = (hit.transform.position - transform.position).normalized;
transform.up = Vector3.Slerp(transform.up, myTargetDirection, Time.deltaTime * rotationSpeed);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment