当前位置:网站首页>Unity development --- the mouse controls the camera to move, rotate and zoom
Unity development --- the mouse controls the camera to move, rotate and zoom
2022-07-07 22:22:00 【Hey, hey, hey, hey, hey】
void Update()
{
float scrollWheel = Input.GetAxis("Mouse ScrollWheel");
if(scrollWheel != 0)
{
Camera_Scale(scrollWheel);
}
else if(Input.GetKeyDown(KeyCode.LeftAlt))// Press down Alt key
{
if(Input.GetMouseButton(0))
{
Camera_Rotate();
}
}
else if(Input.GetMouseButton(2))
{
Camera_Move();
}
}
private void Camera_Scale(float scrollWheel)
{
scrollWheel = scrollWheel * Time.DeltaTime * 500;
transform.Translate(Vector3.forward * wheel);
}
private void Camera_Rotate()
{
float mouseX = Input.GetAxis("Mouse X");
float mouseY = Input.GetAxis("Mouse Y");
transform.RotateAround(transform.position, Vector3.up, mouseX * 5);
transform.RotateAround(transform.position, transform.right, -mouseY * 5);
}
private void Camera_Move()
{
float mouseX = Input.GetAxis("Mouse X");
float mouseY = Input.GetAxis("Mouse Y");
transform.Translate(Vector3.left * mouseX);
transform.Translate(Vector3.up * mouseY * -1);
}边栏推荐
- EasyCVR配置中心录像计划页面调整分辨率时的显示优化
- Typescript TS basic knowledge type declaration
- Have you ever been confused? Once a test / development programmer, ignorant gadget C bird upgrade
- 100million single men and women "online dating", supporting 13billion IPOs
- SAR影像质量评估
- Jerry's initiation of ear pairing, reconnection, and opening of discoverable and connectable cyclic functions [chapter]
- 23. Merge K ascending linked lists -c language
- Which financial products will yield high returns in 2022?
- TCP/IP 协议栈
- OpenGL jobs - shaders
猜你喜欢

使用 BlocConsumer 同时构建响应式组件和监听状态

. Net automapper use

PKPM 2020软件安装包下载及安装教程

The function is really powerful!
![[open source] Net ORM accessing Firebird database](/img/a2/4eff4f0af53bf3b9839a73019a212f.png)
[open source] Net ORM accessing Firebird database

How to make agile digital transformation strategy for manufacturing enterprises

The strongest installation of the twin tower model, Google is playing "antique" again?

EasyCVR配置中心录像计划页面调整分辨率时的显示优化
![[JDBC Part 1] overview, get connection, CRUD](/img/53/d79f29f102c81c9b0b7b439c78603b.png)
[JDBC Part 1] overview, get connection, CRUD

Matplotlib快速入门
随机推荐
Debugging and handling the problem of jamming for about 30s during SSH login
Pre sale 179000, hengchi 5 can fire? Product power online depends on how it is sold
Where is the big data open source project, one-stop fully automated full life cycle operation and maintenance steward Chengying (background)?
Record layoutrebuild Forcerebuildlayoutimmediate does not take effect
How to choose the appropriate automated testing tools?
Jerry's test box configuration channel [chapter]
Kirin Xin'an operating system derivative solution | storage multipath management system, effectively improving the reliability of data transmission
Firefox browser installation impression notes clipping
Lingyun going to sea | saihe & Huawei cloud: jointly help the sustainable development of cross-border e-commerce industry
PKPM 2020 software installation package download and installation tutorial
The free styling service of Dyson's official direct store is now open for appointment. Pioneer Technology interprets the styling concept of hair care and helps consumers unlock diversified and shiny s
SAR image quality evaluation
[开源] .Net ORM 访问 Firebird 数据库
Interview question 01.02 Determine whether it is character rearrangement - auxiliary array algorithm
Matplotlib快速入门
Kaggle-Titanic
Preparing for the interview and sharing experience
How does win11 time display the day of the week? How does win11 display the day of the week today?
How to quickly check whether the opening area ratio of steel mesh conforms to ipc7525
Record a garbled code during servlet learning