This is attached to the Player object—it requires a Rigidbody and CapsuleCollider component, as follows:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerBehavior : MonoBehaviour
{
public float moveSpeed = 10f;
public float rotateSpeed = 75f;
public float jumpVelocity = 5f;
public float distanceToGround = 0.1f;
public LayerMask groundLayer;
public GameObject bullet;
public float bulletSpeed = 100f;
public delegate void JumpingEvent(bool isGrounded);
public event JumpingEvent playerJump;
private float _vInput;
private float _hInput;
private Rigidbody _rb;
private CapsuleCollider _col;
private GameBehavior _gameManager;
void Start()
{
_rb = GetComponent<Rigidbody>();
_col = GetComponent<CapsuleCollider>();
_gameManager = GameObject.Find("Game Manager").GetComponent<GameBehavior>();
}
void Update()
...