Rotation to a .fbx model ...... on click rotation
I am new to unity .... I have a model with .fbx extension . The model is chair on that i tried a script like colour chaning to chair..... bt when i am trying for that onclick rotation it's not working ... ia am not getting whats getting ................ when the same code i use for cube from the game object it work grate.... i want to know what the problem with .fbx model of chair
Assets used for to implement this code is here https://www.assetstore.unity3d.com/en/#!/content/11859
It's a code for rotation : using UnityEngine; using System.Collections;
public class rotate : MonoBehaviour {
private float baseAngle = 0.0f;
void OnMouseDown(){
Vector3 pos = Camera.main.WorldToScreenPoint(transform.position);
pos = Input.mousePosition - pos;
baseAngle = Mathf.Atan2(pos.y, pos.x) * Mathf.Rad2Deg;
baseAngle -= Mathf.Atan2(transform.right.y, transform.right.x) *Mathf.Rad2Deg;
}
void OnMouseDrag(){
Vector3 pos = Camera.main.WorldToScreenPoint(transform.position);
pos = Input.mousePosition - pos;
float ang = Mathf.Atan2(pos.y, pos.x) *Mathf.Rad2Deg - baseAngle;
transform.rotation = Quaternion.AngleAxis(ang, Vector3.forward);
}
}
Comment