当前位置:网站首页>La caméra Unity tourne avec la souris
La caméra Unity tourne avec la souris
2022-04-23 04:41:00 【Long chubby 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()
{
//Mouvement de la caméra
//float x = Input.GetAxis("Horizontal") * Time.deltaTime * 5;
//float y = Input.GetAxis("Vertical") * Time.deltaTime * 5;
//transform.Translate(x, 0, y);
// Limiter la portée du Mouvement de la caméra
//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);
// Clic droit pour faire tourner la caméra
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);
}
}
}
版权声明
本文为[Long chubby Blog]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230441112442.html
边栏推荐
- 第四章 --- 了解标准设备文件、过滤器和管道
- Record the blind injection script
- 【论文阅读】【3d目标检测】point transformer
- Supplement 14: cmake practice project notes (to be continued 4 / 22)
- 520. Detect capital letters
- Redis command Encyclopedia
- leetcode005--原地删除数组中的重复元素
- Go reflection rule
- Installation du compilateur croisé de la plateforme zynq
- Go 语言中的 logger 和 zap 日志库
猜你喜欢
基于英飞凌MCU GTM模块的无刷电机驱动方案开源啦
Installation and use of Apache bench (AB pressure test tool)
win10, mysql-8.0.26-winx64. Zip installation
Phishing for NFT
Supplement 14: cmake practice project notes (to be continued 4 / 22)
AWS EKS添加集群用户或IAM角色
【论文阅读】【3d目标检测】Improving 3D Object Detection with Channel-wise Transformer
Microbial neuroimmune axis -- the hope of prevention and treatment of cardiovascular diseases
win10, mysql-8.0.26-winx64.zip 安装
Supplement: Annotation
随机推荐
leetcode004--罗马数字转整数
unity摄像机旋转带有滑动效果(自转)
Create VPC in AWS console (no plate)
win10, mysql-8.0.26-winx64.zip 安装
Iron and intestinal flora
Leetcode009 -- search the target value in the array with binary search
Coinbase:关于跨链桥的基础知识、事实和统计数据
Huawei machine test -- high precision integer addition
Chlamydia infection -- causes, symptoms, treatment and Prevention
【时序】基于 TCN 的用于序列建模的通用卷积和循环网络的经验评估
[paper reading] [3D object detection] voxel transformer for 3D object detection
229. Find mode II
Record your own dataset with d435i, run orbslam2 and build a dense point cloud
Brushless motor drive scheme based on Infineon MCU GTM module
leetcode008--实现strStr()函数
leetcode009--用二分查找在数组中搜索目标值
【论文阅读】【3d目标检测】Improving 3D Object Detection with Channel-wise Transformer
协程与多进程的完美结合
Eight misunderstandings that should be avoided in data visualization
2021数学建模国赛一等奖经验总结与分享