当前位置:网站首页>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
边栏推荐
- Leetcode004 -- Roman numeral to integer
- 【论文阅读】【3d目标检测】point transformer
- leetcode001--返回和为target的数组元素的下标
- 做数据可视化应该避免的8个误区
- Code007 -- determine whether the string in parentheses matches
- MYSQL50道基础练习题
- Chlamydia infection -- causes, symptoms, treatment and Prevention
- Recommended scheme of national manufactured electronic components for intelligent electronic scales
- win10, mysql-8.0.26-winx64. Zip installation
- 重剑无锋,大巧不工
猜你喜欢
AWS eks add cluster user or Iam role
Mysql50 basic exercises
AWS EKS添加集群用户或IAM角色
Microbial neuroimmune axis -- the hope of prevention and treatment of cardiovascular diseases
Spark FAQ sorting - must see before interview
IDE idea automatic compilation and configuration of on update action and on frame deactivation
How to regulate intestinal flora? Introduction to common natural substances, probiotics and prebiotics
QML advanced (IV) - drawing custom controls
Small volume Schottky diode compatible with nsr20f30nxt5g
Recommended scheme of national manufactured electronic components
随机推荐
Small volume Schottky diode compatible with nsr20f30nxt5g
Recommended scheme of national manufactured electronic components
Go reflection - go language Bible learning notes
thymeleaf th:value 为null时报错问题
2021数学建模国赛一等奖经验总结与分享
leetcode009--用二分查找在数组中搜索目标值
MySQL - data read / write separation, multi instance
2019 is coming to an end, the longest day.
【论文阅读】【3d目标检测】Improving 3D Object Detection with Channel-wise Transformer
Summary of MySQL de duplication methods
mysql ,binlog 日志查询
Apache Bench(ab 压力测试工具)的安装与使用
优麒麟 22.04 LTS 版本正式发布 | UKUI 3.1开启全新体验
Installation and deployment of Flink and wordcount test
Supplement: Annotation
Unity摄像头跟随鼠标旋转
Spark FAQ sorting - must see before interview
Inverse system of RC low pass filter
unity摄像机旋转带有滑动效果(自转)
520.检测大写字母