Почему движение по диагонали быстрее чем вверх(вбок)?
Добавлено: 18 мар 2018, 17:17
Есть объект который вот так управляется джостиком,но при движении по диагонали - обьект движется быстрее чем просто вверх или вбок.Почему так происходит если вектор
rb.AddForce (moveVec.normalized* moveForce) нормализован? Может нужно что-то в физике проекта исправить?
rb.AddForce (moveVec.normalized* moveForce) нормализован? Может нужно что-то в физике проекта исправить?
Синтаксис:
Используется csharp
using UnityStandardAssets.CrossPlatformInput;
void FixedUpdate () {
Vector3 moveVec = new Vector3(CrossPlatformInputManager.GetAxis ("Horizontal"), CrossPlatformInputManager.GetAxis ("Vertical"),4096) ;
if (moveVec.x != 0 && moveVec.y != 0)
targetRotation = Quaternion.LookRotation (moveVec.normalized, Vector3.back.normalized);
transform.rotation= Quaternion.Slerp (transform.rotation, targetRotation, rotationForce * Time.deltaTime);
rb.AddForce (moveVec.normalized* moveForce);
}
void FixedUpdate () {
Vector3 moveVec = new Vector3(CrossPlatformInputManager.GetAxis ("Horizontal"), CrossPlatformInputManager.GetAxis ("Vertical"),4096) ;
if (moveVec.x != 0 && moveVec.y != 0)
targetRotation = Quaternion.LookRotation (moveVec.normalized, Vector3.back.normalized);
transform.rotation= Quaternion.Slerp (transform.rotation, targetRotation, rotationForce * Time.deltaTime);
rb.AddForce (moveVec.normalized* moveForce);
}