Hi i have a UI Root(3d) and i also have a 3d object that i want to rotate it with Lerp, my object rotate perfectly with unity Camera but when i add NGUI 3d Camera, it stopped working and i know that my code is not working with NGUI, but is there a way to make it work?
(I KNOW NGUI HAS AN EXAMPLE THAT HAS ROTATE OBJECT BUT THAT DOSEN'T HAVE LERP)
Please help me I'm new to coding
thank you a lot
I Really appreciate it
Here is my code:
using UnityEngine;
using System.Collections;
public class DragRotateSlowdown : MonoBehaviour {
public float rotationSpeed = 10.0F;
public float lerpSpeed = 1.0F;
private Vector3 theSpeed;
private Vector3 avgSpeed;
private bool isDragging = false;
private Vector3 targetSpeedX;
void OnMouseDown() {
isDragging = true;
}
void Update() {
if (Input.touchCount > 0 && isDragging) {
theSpeed
= new Vector3
(-Input
.touches[0].deltaPosition.x, Input
.touches[0].deltaPosition.y, 0
.0F
); avgSpeed = Vector3.Lerp(avgSpeed, theSpeed, Time.deltaTime * 5);
} else {
if (isDragging) {
theSpeed = avgSpeed;
isDragging = false;
}
float i = Time.deltaTime * lerpSpeed;
theSpeed = Vector3.Lerp(theSpeed, Vector3.zero, i);
}
transform.Rotate(Camera.main.transform.up * theSpeed.x * rotationSpeed, Space.World);
transform.Rotate(Camera.main.transform.right * theSpeed.y * rotationSpeed, Space.World);
}
}