using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.InputSystem; public class CameraMove : MonoBehaviour { //private float moveSpeed = 3.5f; //private float rotaveSpeed = 8f; //private Vector3 moveDirection; //private Vector3 angleDirection; //private void Update() //{ // if(Mouse.current.rightButton.isPressed) // { // MouseRotation(); // KeyboardMove(); // } // angleDirection = transform.eulerAngles; //} //// ¸¶¿ì½º ȸÀü //void MouseRotation() //{ // float yRotateSize = Mouse.current.delta.x.ReadValue(); // float xRotateSize = Mouse.current.delta.y.ReadValue(); // angleDirection += new Vector3(xRotateSize, yRotateSize, 0) * rotaveSpeed * Time.deltaTime; // //xRotate = Mathf.Clamp(xRotate + xRotateSize, -80, 30); // transform.eulerAngles = angleDirection; //} //// Űº¸µå À̵¿ //void KeyboardMove() //{ // transform.position = ClampPosition(); // transform.Translate(moveDirection * moveSpeed * Time.deltaTime); //} //// À̵¿ À§Ä¡ Á¦ÇÑ //Vector3 ClampPosition() //{ // return new Vector3( // Mathf.Clamp(transform.position.x, -8f, 8f), // Mathf.Clamp(transform.position.y, 0.4f, 5f), // Mathf.Clamp(transform.position.z, 3f, 26f) // ); //} //// Űº¸µå ÀÎDz °¨Áö //void OnMove(InputValue value) //{ // Vector2 input = value.Get(); // if (input != null) // { // moveDirection = new Vector3(input.x, 0f, input.y); // } // else // { // moveDirection = Vector3.zero; // } //} public GameObject robot; private float angle = 0.2f; private bool isMoving = false; private Vector3 originPos; private Vector3 originRotation; private void Start() { originPos = transform.position; originRotation = transform.eulerAngles; } private void Update() { if(isMoving) { if (transform.eulerAngles.y >= 270f || transform.eulerAngles.y <= 90f) { angle = -angle; } transform.RotateAround(robot.transform.position, Vector3.up, angle); transform.LookAt(robot.transform); } else { transform.position = originPos; transform.eulerAngles = originRotation; } } public void OnClickCameraBtn() { isMoving = !isMoving; } }