c# - 如何在移动设备上仅旋转屏幕的一部分的播放器(立方体)?
问题描述
如果我触摸屏幕并将手指移动到屏幕的某一部分,我不知道如何旋转播放器。 https://imgur.com/1xDSWtA这是我要旋转立方体的部分。
解决方案
将脚本添加到多维数据集,如下所示:
void Update()
{
if(Input.touches > 0)
{
Touch touch = Input.GetTouch(0);
Vector2 pos = touch.position;
float width_fraction = pos.x / (float)Screen.width;
// only run this, if finger is on the right half (50%)
if(width_fraction > 0.5)
{
this.transform.Rotate(0, Time.deltatime * 30f, 0); // rotate 30 Deg per second
}
}
}
推荐阅读
- php - 我们什么时候必须在 php 中使用“条件”函数?
- vue.js - Rollup,VueJS,安装 Vue 传送门
- android - 在android中录制的音频转换为Base 64
- mysql - 如何在 MySQL 中获取上一个最后一行
- r - 当数据只有一个类别时显示颜色图例
- python - 当从python中的文本文件中读取一行时,每行一个单词,然后在添加另一行后用文本打印该行
- quill - Quill 文本编辑器 - 保存按钮
- java - Azure 构建管道无法从 azure artifact 下载依赖项,
- java - 在 JOOQ 中使用 NOWAIT 和 SKIP LOCKED 子句的解决方法
- arrays - mongodb用户表与好友