using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerController : MonoBehaviour
{
public float speed;
public float jumpForce;
public CharacterController controller;
private Vector3 moveDirec;
public float gravityScale;
void Start()
{
controller.GetComponent<CharacterController>();
}
void Update()
{
moveDirec = new Vector3(Input.GetAxis("Horizontal") * speed, moveDirec.y);
if (controller.isGrounded && Input.GetButtonDown("Jump"))
{
moveDirec.y = jumpForce;
}
moveDirec.y = moveDirec.y + (Physics.gravity.y * gravityScale);
controller.Move(moveDirec * Time.deltaTime);
if (Input.GetAxis("Horizontal") < -0.001f)
{
transform.Rotate(0f, 180f, 0f);
}
if (Input.GetAxis("Horizontal") < 0.001f)
{
transform.Rotate(0f, -180f, 0f);
}
}
}
It’s spazzing out and I don’t know why…
Clip: Desktop 2019.03.18 - 20.32.53.02 GIF | Gfycat