This repository has been archived on 2026-01-20. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
URRobot/Assets/Scripts/UI/CameraMove.cs
jmaniuvc 282fcfe688 main
2025-05-29 09:51:58 +09:00

108 lines
2.6 KiB
C#

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)
// );
//}
//// 키보드 인풋 감지
//void OnMove(InputValue value)
//{
// Vector2 input = value.Get<Vector2>();
// 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;
}
}