Значения векторов отображаются корректно, но вот само вращение - нет. Скажем если значение Global.manom1 = 100, то угол меняется с 58 до 61.9. А если 150, то 64, хотя очевидно, что так быть не должно.
Если пользоваться transform.Rotate, то стрелка просто вращается без остановки.
С координатами зато творится что-то непонятное, такое впечатление, что на границе каждой четверти(или половины, не совсем понятно) отсчет начинается заново. Что делать то? Как заставить двигаться стрелку от одного положения к другому.
Очень надеюсь на помощь! И заранее спасибо!
Синтаксис:
Используется csharp
using UnityEngine;
using System.Collections;
public class manom1 : MonoBehaviour {
private Vector3 defaultRot;
private Vector3 curRot;
float smooth = 2;
// Use this for initialization
void Start(){
}
// Update is called once per frame
void Update () {
//Debug.Log(Global.manom2);
if(Global.izm1){
defaultRot = transform.eulerAngles;
Debug.Log(Global.manom1);
Debug.Log(defaultRot);
curRot = new Vector3 (defaultRot.x + Global.manom1, defaultRot.y, defaultRot.z);
Debug.Log(curRot);
transform.eulerAngles = Vector3.Slerp(transform.eulerAngles, curRot, Time.deltaTime * smooth);
Debug.Log(curRot);
Global.izm1 = false;
}
//transform.Rotate(Vector3.left, Time.deltaTime * 100);
}
}
using System.Collections;
public class manom1 : MonoBehaviour {
private Vector3 defaultRot;
private Vector3 curRot;
float smooth = 2;
// Use this for initialization
void Start(){
}
// Update is called once per frame
void Update () {
//Debug.Log(Global.manom2);
if(Global.izm1){
defaultRot = transform.eulerAngles;
Debug.Log(Global.manom1);
Debug.Log(defaultRot);
curRot = new Vector3 (defaultRot.x + Global.manom1, defaultRot.y, defaultRot.z);
Debug.Log(curRot);
transform.eulerAngles = Vector3.Slerp(transform.eulerAngles, curRot, Time.deltaTime * smooth);
Debug.Log(curRot);
Global.izm1 = false;
}
//transform.Rotate(Vector3.left, Time.deltaTime * 100);
}
}