using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerController : MonoBehaviour {
public float speed;
public float jumpSpeed;
public float airSpeed;
public CharacterController player;
private Vector3 moveDirection;
private Vector3 jumpVelocity = Vector3.zero;
// Use this for initialization
void Start () {
player = GetComponent<CharacterController>();
}
// Update is called once per frame
void Update()
{
Vector3 moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
moveDirection = transform.TransformDirection(moveDirection);
if (player.isGrounded)
{
moveDirection.x *= speed;
moveDirection.z *= speed;
if (Input.GetButton("Jump"))
{
moveDirection.y = jumpSpeed;
}
else
{
moveDirection.y = 0;
}
}
else
{
moveDirection.x *= airSpeed;
moveDirection.z *= airSpeed;
moveDirection.y += Physics.gravity.y * Time.deltaTime;
}
player.Move((moveDirection + jumpVelocity) * Time.deltaTime);
}
}
Can you post an image of the inspector for you player controller?
– Vega4Life