unity 利用四元数旋转向量时出错 解决方法
2018-02-09 13:39
435 查看
Ray front_ray_car_left = new Ray(frontLidar.position, frontLidar.forward * Quaternion.Euler(0, -45f, 0));
此句代码报错:
Operator `*' cannot be applied to operands of type `UnityEngine.Vector3' and `UnityEngine.Quaternion'
经过查手册发现,是因为Vector3类型没有与Quaternion类型有运算符*的重载,而Quaternion类有与Vector3的*重载
所以将代码改为
Ray front_ray_car_left = new Ray(frontLidar.position, Quaternion.Euler(0, -45f, 0) * frontLidar.forward);
就可以通过编译了。
此句代码报错:
Operator `*' cannot be applied to operands of type `UnityEngine.Vector3' and `UnityEngine.Quaternion'
经过查手册发现,是因为Vector3类型没有与Quaternion类型有运算符*的重载,而Quaternion类有与Vector3的*重载
所以将代码改为
Ray front_ray_car_left = new Ray(frontLidar.position, Quaternion.Euler(0, -45f, 0) * frontLidar.forward);
就可以通过编译了。
相关文章推荐
- unity发布失败,文件读取出错的解决方法(The file 'resources.assets' is corrupted)
- <编程珠玑>向量旋转(旋转交换) 第三种方法实现代码, 杂耍,其实也没那么容易出错.
- unity-----------------------四元数与欧拉旋转方法
- unity入门教程之使用四元数旋转向量
- windows server2014 安装 Mysql Applying Security出错的完美解决方法
- php session_start()出错原因分析及解决方法
- php session_start()出错原因分析及解决方法
- Unity UGUI —— 鼠标穿透UI问题(Unity官方的解决方法)
- 解决混合模式程序集在VS2010 .net 4.0 环境下调试出错的方法。
- html5新特性:利用history的pushState等方法来解决使用ajax导致页面后退和前进的问题
- html5新特性:利用history的pushState等方法来解决使用ajax导致页面后退和前进的问题
- ubuntu14.04编译busybox出错解决方法
- JavaScript利用append添加元素报错的解决方法
- "分析 EntityName 时出错"的解决方法
- unity 控制旋转的方法
- netcore中使用bower还原出错的解决方法
- 关于利用Jsoup解析HTML中&nbsp;变成非传统空格或乱码问题解决方法
- Bmob实现登陆注册,解决官方signUp与Success方法更新后出错问题
- 【Unity】【转】四元数(Quaternion)和旋转