Switch back to sphere casting
This commit is contained in:
@@ -1,21 +0,0 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Scampz.GameJam.Assets.Scripts.Player
|
||||
{
|
||||
public class Player : MonoBehaviour
|
||||
{
|
||||
private Animator _animator;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_animator = GetComponent<Animator>();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
var player = GameObject.FindGameObjectWithTag("Player");
|
||||
var cc = player.GetComponent<CharacterController>();
|
||||
_animator.SetFloat("Speed", cc.velocity.magnitude);
|
||||
}
|
||||
}
|
||||
}
|
||||
30
Assets/Scripts/Player/PlayerState.cs
Normal file
30
Assets/Scripts/Player/PlayerState.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Scampz.GameJam.Assets.Scripts.Player
|
||||
{
|
||||
public class PlayerState : MonoBehaviour
|
||||
{
|
||||
private Animator _animator;
|
||||
private RayCaster _rayCaster;
|
||||
|
||||
private bool _canMove;
|
||||
private GameObject _player;
|
||||
private CharacterController _characterController;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_animator = GetComponent<Animator>();
|
||||
_rayCaster = GetComponent<RayCaster>();
|
||||
_player = GameObject.FindGameObjectWithTag("Player");
|
||||
_characterController = _player.GetComponent<CharacterController>();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
_animator.SetFloat("Speed", _characterController.velocity.magnitude);
|
||||
_canMove = _rayCaster.IsWithinBounds();
|
||||
}
|
||||
|
||||
public bool CanMove => _canMove;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user