40 lines
No EOL
1 KiB
C#
40 lines
No EOL
1 KiB
C#
using UnityEngine;
|
|
|
|
public class PlayerController : MonoBehaviour
|
|
{
|
|
private Rigidbody m_Rigidbody;
|
|
private Camera m_Camera;
|
|
private bool m_IsGrounded = false;
|
|
private bool m_WantJump = false;
|
|
private Vector2 m_MoveInput = Vector2.zero;
|
|
private Vector2 m_LookInput = Vector2.zero;
|
|
private Vector3 m_Velocity = Vector3.zero;
|
|
private float m_MovementSmoothing = .05f;
|
|
private bool m_isColliding = false;
|
|
|
|
void FixedUpdate()
|
|
{
|
|
m_IsGrounded = false;
|
|
RaycastHit hit; // TODO: Use to see if on train later and ground angle if that's relevant
|
|
if (Physics.Raycast(transform.position, Vector3.down, out hit, 1.1f))
|
|
{
|
|
m_IsGrounded = true;
|
|
}
|
|
|
|
}
|
|
|
|
void OnJump()
|
|
{
|
|
if (m_IsGrounded)
|
|
{
|
|
m_Rigidbody.AddForce(new Vector3(0f,400f,0f));
|
|
m_IsGrounded = false;
|
|
}
|
|
}
|
|
|
|
void Awake()
|
|
{
|
|
m_Rigidbody = GetComponent<Rigidbody>();
|
|
m_Camera = GetComponent<Camera>();
|
|
}
|
|
} |