本文介绍了如何使对象面对其前向矢量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
类似于我最近的问题仅这次,我想将对象移向矢量而不是另一个对象.
Similar to my recent question only this time I would like to move the object towards a vector and not another object.
Vector3 line = dalekList[i].direction;
float rotationDal = (float)(-Math.Atan2(dalekList[i].position.X, -dalekList[i].position.Z) / (2 * Math.PI));
Matrix dalekTransform = Matrix.CreateScale(GameConstants.DalekScalar) * Matrix.CreateRotationY(rotationDal) * Matrix.CreateTranslation(dalekList[i].position);
所以我需要将旋转(rotationDal
)放入CreateRotationY
,只是我不确定如何计算该角度.
So I would need to put the rotation (rotationDal
) into the CreateRotationY
, only I'm not sure how to calculate that angle.
推荐答案
如果要观看"的向量是dalekList[i].direction
,则应尝试在其上使用Atan2
而不是位置.
If the vector you want to "watch" is dalekList[i].direction
, you should try to use Atan2
on it, instead of position.
这篇关于如何使对象面对其前向矢量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!