unity3d - Unity 使用 PS4 控制器旋转对象
问题描述
我是 Unity 新手,但我正在尝试使用控制器输入(右摇杆)围绕 Y 轴旋转对象。因此,如果将杆向右推,则对象将向右旋转。到目前为止,这是我的代码。
public class TurnBall : MonoBehaviour {
PlayerControls controls;
Vector2 aim;
void Awake() {
controls = new PlayerControls();
controls.Gameplay.Aim.performed += ctx => aim = ctx.ReadValue<Vector2>();
controls.Gameplay.Aim.canceled += ctx => aim = Vector2.zero;
}
void Update() {
transform.Rotate(0, aim.x, 0, Space.World);
}
void onEnable() {
controls.Gameplay.Enable();
}
void onDisable() {
controls.Gameplay.Disable();
}
}
提前致谢!!
解决方案
推荐阅读
- javascript - 如何在下载前从目录中删除文件
- ruby-on-rails - 错误处理程序的优先级:方法中的rescue_from与rescue
- matlab - 如何使用 for 循环将先前的值添加到 MATLAB 中的数组中?
- oracle - 微调 EXTRACT HOUR 和 DAY
- strapi - Strapi Bundle/Group 集合类型
- java - 通用方法类型参数推理问题
- python - 如何在 sam 本地环境中使用依赖项?
- javascript - JavaScript:使用 MediaRecorder 记录来自的流
- vtk - 如何在 VTK 中使用现有转换转换 Actor
- node.js - 如何在 Sequelize 中检索文件/图像