Transform.LookAt()但仅在X轴上 [英] Transform.LookAt() but only in X-Axis

查看:123
本文介绍了Transform.LookAt()但仅在X轴上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用我的GameObject跟随Transform.LookAt()的功能,通过保持Y和Z轴不变来仅在X轴方向旋转?

How do I use my GameObject to follow the function for Transform.LookAt() only to rotate in the direction of X-Axis, by keeping Y and Z axes unchanged?

transform.LookAt(otherObject.transform);

推荐答案

传递整个对象变换只是传递参数另一个对象x值,而y和z使用当前值

Instead passing the whole object transform just pass on the parameters the other object x value and for the y and z use the currenct values

transform.LookAt(new Vector3(otherObject.position.x, transform.position.y, transform.position.z));

这篇关于Transform.LookAt()但仅在X轴上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆