Re-think singleton player idea, add raycasting to stop from falling off ledges
This commit is contained in:
22
Assets/Scripts/Input/RayCaster.cs
Normal file
22
Assets/Scripts/Input/RayCaster.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Scampz.GameJam.Assets.Scripts
|
||||
{
|
||||
public class RayCaster : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private float rayCastDistance = 1f;
|
||||
|
||||
public bool IsWithinBounds()
|
||||
{
|
||||
var offsetAngle = Quaternion.AngleAxis(45, transform.right);
|
||||
return Physics.Raycast(transform.position, offsetAngle * transform.forward);
|
||||
}
|
||||
|
||||
private void OnDrawGizmosSelected()
|
||||
{
|
||||
var offsetAngle = Quaternion.AngleAxis(45, transform.right);
|
||||
Debug.DrawRay(transform.position, offsetAngle * transform.forward * rayCastDistance);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user