Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class movementScript : MonoBehaviour
- {
- [Range(2,20)]
- public float forwardSpeed;
- [Range(2, 15)]
- public float backwardSpeed;
- [Range(2, 10)]
- public float sideSpeed;
- [Range(1, 300)]
- public int mouseSensibility;
- // Start is called before the first frame update
- void Start()
- {
- }
- // Update is called once per frame
- void LateUpdate()
- {
- transform.eulerAngles += new Vector3(0, Input.GetAxis("Mouse X") * mouseSensibility, 0);
- if (Input.anyKey)
- {
- InputManagement();
- }
- }
- void InputManagement()
- {
- if(Input.GetKey(KeyCode.Z))
- {
- transform.position = transform.position + new Vector3(0, 0, forwardSpeed * Time.deltaTime);
- }
- if (Input.GetKey(KeyCode.S))
- {
- transform.position -= new Vector3(0, 0, backwardSpeed * Time.deltaTime);
- }
- if (Input.GetKey(KeyCode.Q))
- {
- transform.position -= new Vector3(sideSpeed * Time.deltaTime, 0, 0);
- }
- if (Input.GetKey(KeyCode.D))
- {
- transform.position += new Vector3(sideSpeed * Time.deltaTime, 0, 0);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement