当前位置:网站首页>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
边栏推荐
- Improving 3D object detection with channel wise transformer
- Installation du compilateur croisé de la plateforme zynq
- Bridge between ischemic stroke and intestinal flora: short chain fatty acids
- Flink's important basics
- mysql ,binlog 日志查询
- Leetcode005 -- delete duplicate elements in the array in place
- 阿里十年技术专家联合打造“最新”Jetpack Compose项目实战演练(附Demo)
- Druid -- JDBC tool class case
- A lifetime of needs, team collaboration can play this way on cloud nailing applet
- 2021数学建模国赛一等奖经验总结与分享
猜你喜欢

補:注解(Annotation)

Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.

AWS eks add cluster user or Iam role

IDE Idea 自动编译 与 On Upate Action 、 On Frame Deactivation 的配置

How to regulate intestinal flora? Introduction to common natural substances, probiotics and prebiotics

PIP3 installation requests Library - the most complete pit sorting

Druid -- JDBC tool class case

简单的拖拽物体到物品栏

优麒麟 22.04 LTS 版本正式发布 | UKUI 3.1开启全新体验

Practice and exploration of knowledge map visualization technology in meituan
随机推荐
Programmers complain: I really can't live with a salary of 12000. Netizen: how can I say 3000
Gut liver axis: host microbiota interaction affects hepatocarcinogenesis
Microbial neuroimmune axis -- the hope of prevention and treatment of cardiovascular diseases
PIP3 installation requests Library - the most complete pit sorting
Record your own dataset with d435i, run orbslam2 and build a dense point cloud
thymeleaf th:value 为null时报错问题
io.Platform.packageRoot; // ignore: deprecated_member_use
Recommended scheme of national manufactured electronic components for intelligent electronic scales
Coinbase: basic knowledge, facts and statistics about cross chain bridge
Shanghai Hangxin technology sharing 𞓜 overview of safety characteristics of acm32 MCU
Ali's ten-year technical experts jointly created the "latest" jetpack compose project combat drill (with demo)
MYSQL去重方法汇总
QML advanced (IV) - drawing custom controls
Bridge between ischemic stroke and intestinal flora: short chain fatty acids
Leetcode002 -- inverts the numeric portion of a signed integer
Brushless motor drive scheme based on Infineon MCU GTM module
Supplément: annotation
用D435i录制自己的数据集运行ORBslam2并构建稠密点云
How to regulate intestinal flora? Introduction to common natural substances, probiotics and prebiotics
MYSQL50道基础练习题