Поворачиваю объект по оси y. Поворот на нужный угол проиходит, но объект двигается вперёд всё время обратной стороной, т.е. тыльной стороной. Вот код
Синтаксис:
Используется csharp
if (hit.collider.gameObject.name == "Terrain")
{
//var tr = ray.GetPoint(0.0f);
Vector3 end = new Vector3(hit.point.x, this.transform.position.y, hit.point.z);
Vector3 toRotation = end - transform.position;
// var angleToTarget = Vector3.Angle(transform.position, end);
//WrapAngle(ref angleToTarget);
//var rotatedLine = Quaternion.AngleAxis(angleToTarget, transform.);
//var myForward = transform.rotation * Vector3.up;
var rotate = Quaternion.LookRotation(Vector3.up, toRotation);
this.transform.rotation = rotate;
// this.transform.rotation = Quaternion.Slerp(this.transform.rotation,
// rotate, Time.deltaTime * 2.0f);//Quaternion.Lerp(fromRotation, toRotation, Time.deltaTime * 2);
StartCoroutine(MoveDuration(this.transform, end, 3));
}
{
//var tr = ray.GetPoint(0.0f);
Vector3 end = new Vector3(hit.point.x, this.transform.position.y, hit.point.z);
Vector3 toRotation = end - transform.position;
// var angleToTarget = Vector3.Angle(transform.position, end);
//WrapAngle(ref angleToTarget);
//var rotatedLine = Quaternion.AngleAxis(angleToTarget, transform.);
//var myForward = transform.rotation * Vector3.up;
var rotate = Quaternion.LookRotation(Vector3.up, toRotation);
this.transform.rotation = rotate;
// this.transform.rotation = Quaternion.Slerp(this.transform.rotation,
// rotate, Time.deltaTime * 2.0f);//Quaternion.Lerp(fromRotation, toRotation, Time.deltaTime * 2);
StartCoroutine(MoveDuration(this.transform, end, 3));
}
Что делаю не так?