1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class CameraMove : MonoBehaviour
- {
- public float moveSpped = 100;
- public float roteSpped = 100;
- public float smooth = 2;
- public string horizontal = "Horizontal";
- public string vertical = "Vertical";
- public string mouseX = "Mouse X";
- public string mouseY = "Mouse Y";
- public string fire2 = "Fire2";
- public string mouseScrollWheel = "Mouse ScrollWheel";
- private Vector2 angele;
- private Quaternion rotation;
- private void Awake()
- {
- #if !UNITY_EDITOR
- enabled = false;
- #endif
- angele = transform.eulerAngles;
- }
- // Update is called once per frame
- void Update()
- {
- if (Input.GetButton(fire2))
- {
- angele.x -= Input.GetAxis(mouseY) * roteSpped * Time.deltaTime;
- angele.x = Mathf.Clamp(angele.x, -90, 90);
- angele.y += Input.GetAxis(mouseX) * roteSpped * Time.deltaTime;
- transform.eulerAngles = angele;
- }
- if (Input.GetButton(horizontal))
- {
- transform.Translate(transform.right.normalized * Input.GetAxis(horizontal) * Time.deltaTime * moveSpped, Space.World);
- }
- if (Input.GetButton(vertical))
- {
- transform.Translate(transform.forward.normalized * Input.GetAxis(vertical) * Time.deltaTime * moveSpped, Space.World);
- }
- }
- }
|