当前位置:网站首页>Unity攝像頭跟隨鼠標旋轉
Unity攝像頭跟隨鼠標旋轉
2022-04-23 04:41:00 【龍胖胖的博客】
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()
{
//攝像頭移動
//float x = Input.GetAxis("Horizontal") * Time.deltaTime * 5;
//float y = Input.GetAxis("Vertical") * Time.deltaTime * 5;
//transform.Translate(x, 0, y);
//限制攝像頭移動的範圍
//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);
//點擊鼠標右鍵旋轉攝像頭
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);
}
}
}
版权声明
本文为[龍胖胖的博客]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230441112442.html
边栏推荐
- io. Platform. packageRoot; // ignore: deprecated_ Member_ use
- shell wc (统计字符数量)的基本使用
- IEEE Transactions on Industrial Informatics(TII)投稿须知
- Practice and exploration of knowledge map visualization technology in meituan
- Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
- mysql table 中增加列的SQL语句
- 1个需求的一生,团队协作在云效钉钉小程序上可以这么玩
- Gut liver axis: host microbiota interaction affects hepatocarcinogenesis
- Redis command Encyclopedia
- leetcode008--实现strStr()函数
猜你喜欢
Bridge between ischemic stroke and intestinal flora: short chain fatty acids
优麒麟 22.04 LTS 版本正式发布 | UKUI 3.1开启全新体验
Youqilin 22.04 lts version officially released | ukui 3.1 opens a new experience
Chapter 4 - understanding standard equipment documents, filters and pipelines
A new method for evaluating the quality of metagenome assembly - magista
QML进阶(五)-通过粒子模拟系统实现各种炫酷的特效
Fusobacterium -- symbiotic bacteria, opportunistic bacteria, oncobacterium
递归调用--排列的穷举
补:注解(Annotation)
基于英飞凌MCU GTM模块的无刷电机驱动方案开源啦
随机推荐
简单的拖拽物体到物品栏
Practice and exploration of knowledge map visualization technology in meituan
520.检测大写字母
【时序】基于 TCN 的用于序列建模的通用卷积和循环网络的经验评估
Summary of Android development posts I interviewed in those years (attached test questions + answer analysis)
The 14th issue of HMS core discovery reviews the long article | enjoy the silky clip and release the creativity of the video
Redis command Encyclopedia
RC低通滤波器的逆系统
Installation and use of Apache bench (AB pressure test tool)
Use recyclerview to realize left-right side-by-side classification selection
补:注解(Annotation)
New terminal play method: script guidance independent of technology stack
[timing] empirical evaluation of general convolution and cyclic networks for sequence modeling based on TCN
io. Platform. packageRoot; // ignore: deprecated_ Member_ use
KVM error: Failed to connect socket to ‘/var/run/libvirt/libvirt-sock‘
Mysql50 basic exercises
Eksctl deploying AWS eks
[paper reading] [3D target detection] point transformer
电钻、电锤、电镐的区别
Druid -- JDBC tool class case