2020-11-17 15:14:13 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
public abstract class CharacterControllerBase : MonoBehaviour
|
|
|
|
{
|
|
|
|
protected Rigidbody2D _rb;
|
2020-11-17 23:11:03 +00:00
|
|
|
|
|
|
|
public Transform foot;
|
|
|
|
public float groundRadius;
|
|
|
|
public LayerMask groundMask;
|
2020-11-17 15:14:13 +00:00
|
|
|
|
|
|
|
public bool IsOnGround(string groundName = "")
|
|
|
|
{
|
2020-11-17 23:11:03 +00:00
|
|
|
var collider = Physics2D.OverlapCircle(foot.position, groundRadius, groundMask);
|
|
|
|
return collider && (groundName.Length == 0 || collider.name.StartsWith(groundName));
|
2020-11-17 15:14:13 +00:00
|
|
|
}
|
|
|
|
}
|