当前位置:网站首页>The unity camera rotates with the mouse
The unity camera rotates with the mouse
2022-04-23 04:41:00 【Longpangpang's blog】
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraMove : MonoBehaviour {
float _rotationX;
float rotationY;
public float sensitivityHor = 5.0f;
public float sensitivityVert = 5.0f;
public float minimumVert = -45.0f;
public float maximumVert = 45.0f;
// Update is called once per frame
void Update()
{
// The camera moves
//float x = Input.GetAxis("Horizontal") * Time.deltaTime * 5;
//float y = Input.GetAxis("Vertical") * Time.deltaTime * 5;
//transform.Translate(x, 0, y);
// Limit the range of camera movement
//float move_x = Mathf.Clamp(transform.position.x, -20f, 20f);
//float move_y = Mathf.Clamp(transform.position.y, -20f, 20f);
//float move_z = Mathf.Clamp(transform.position.z, -20f, 20f);
//transform.position = new Vector3(move_x, move_y, move_z);
// Click the right mouse button to rotate the camera
if (Input.GetMouseButton(1))
{
rotationY = transform.localEulerAngles.y + Input.GetAxis("Mouse X") * sensitivityHor;
_rotationX -= Input.GetAxis("Mouse Y") * sensitivityVert;
_rotationX = Mathf.Clamp(_rotationX, minimumVert, maximumVert);
transform.localEulerAngles = new Vector3(_rotationX, rotationY, 0);
}
}
}
版权声明
本文为[Longpangpang's blog]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230441112442.html
边栏推荐
- 做数据可视化应该避免的8个误区
- win10, mysql-8.0.26-winx64. Zip installation
- 阿里十年技术专家联合打造“最新”Jetpack Compose项目实战演练(附Demo)
- Fusobacterium -- symbiotic bacteria, opportunistic bacteria, oncobacterium
- Installation du compilateur croisé de la plateforme zynq
- IDE Idea 自动编译 与 On Upate Action 、 On Frame Deactivation 的配置
- leetcode001--返回和为target的数组元素的下标
- Recommended scheme of national manufactured electronic components for intelligent electronic scales
- IDE idea automatic compilation and configuration of on update action and on frame deactivation
- Chlamydia infection -- causes, symptoms, treatment and Prevention
猜你喜欢
MYSQL50道基础练习题
Recommended scheme of national manufactured electronic components
Installation of zynq platform cross compiler
zynq平台交叉编译器的安装
C language: Advanced pointer
简单的拖拽物体到物品栏
Recommended scheme of national manufactured electronic components for intelligent electronic scales
Summary of Android development posts I interviewed in those years (attached test questions + answer analysis)
Installation and use of Apache bench (AB pressure test tool)
RC低通滤波器的逆系统
随机推荐
Mysql, binlog log query
MySQL - data read / write separation, multi instance
Summary of MySQL de duplication methods
229. 求众数 II
IDE idea automatic compilation and configuration of on update action and on frame deactivation
MYSQL查询至少连续n天登录的用户
win10, mysql-8.0.26-winx64.zip 安装
Ali's ten-year technical experts jointly created the "latest" jetpack compose project combat drill (with demo)
Leetcode - > 1 sum of two numbers
RC低通滤波器的逆系统
递归调用--排列的穷举
补:注解(Annotation)
Practice and exploration of knowledge map visualization technology in meituan
补充番外14:cmake实践项目笔记(未完待续4/22)
IEEE Transactions on industrial information (TII)
【论文阅读】【3d目标检测】point transformer
AWS eks add cluster user or Iam role
优麒麟 22.04 LTS 版本正式发布 | UKUI 3.1开启全新体验
在AWS控制台创建VPC(无图版)
1个需求的一生,团队协作在云效钉钉小程序上可以这么玩