How to make an object face its forward vector

℡╲_俬逩灬. 提交于 2019-12-13 04:39:18

问题


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);

So I would need to put the rotation (rotationDal) into the CreateRotationY, only I'm not sure how to calculate that angle.


回答1:


If the vector you want to "watch" is dalekList[i].direction, you should try to use Atan2 on it, instead of position.



来源:https://stackoverflow.com/questions/20520739/how-to-make-an-object-face-its-forward-vector

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!