Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class PlayerController : MonoBehaviour
- {
- // Start is called before the first frame update
- void Start()
- {
- }
- // Update is called once per frame
- public float speed = 20;
- public float turnSpeed;
- public float turnInput;
- public float turnForward;
- void Update()
- {
- turnInput = Input.GetAxis("Horizontal");
- turnForward = Input.GetAxis("Vertical");
- transform.Translate(Vector3.forward * Time.deltaTime * speed * turnForward);
- // Only rotate if moving forward or backward
- if (turnForward != 0)
- {
- transform.Rotate(Vector3.up, turnSpeed * turnInput * Time.deltaTime);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment