Merge pull request #6 from gjcampbell777/player_rotation

Added simple player rotation
This commit is contained in:
Gregory Campbell
2019-10-06 20:32:33 -04:00
committed by GitHub
+4
View File
@@ -14,6 +14,7 @@ public class PlayerController : MonoBehaviour
public float speed = 20.0f;
public float jumpSpeed = 15.0f;
public float gravity = 5.0f;
public float rotationSpeed = 150.0f;
private bool extraJump = true;
private Vector3 moveDirection;
@@ -29,6 +30,9 @@ public class PlayerController : MonoBehaviour
float yStore = moveDirection.y;
moveDirection = (transform.forward * Input.GetAxisRaw("Vertical")) + (transform.right * Input.GetAxisRaw("Horizontal"));
//Player rotation
transform.Rotate(0, Input.GetAxis("Horizontal") * Time.deltaTime * rotationSpeed, 0);
if (extraJump == true)
{
moveDirection = moveDirection.normalized * speed; //Remove this line to make running diagonal the fastest standard run