- Home /
Question by
shannonchoo · Mar 19, 2021 at 09:36 AM ·
animationmouse-drag
How do I play my animation on my 3D object while being able to use the MouseDragRotate to have a 360 view of it ?
Currently, I have a 3D object - a rack, in which I have set an animation to it. When I press a button, it will play the animation - the drawer of the rack will open.
However, I would like to allow the user to have a 360 view of the rack, while the animation is playing. The script that I currently have in order to move the object using mouse drag is:
void OnMouseDrag()
{
float XaxisRotation = Input.GetAxis("Mouse X") * rotationSpeed;
float YaxisRotation = Input.GetAxis("Mouse Y") * rotationSpeed;
GameObject.FindWithTag("Model").transform.Rotate(Vector3.down, XaxisRotation);
GameObject.FindWithTag("Model").transform.Rotate(Vector3.right, YaxisRotation);
}
But when I load both of the components together, it does not work. When the button is clicked to open the drawers of the rack, the drawer which is assigned the animation to, will disappear.
Is there anyone who knows how I can integrate this together ? Any help would be greatly appreciated.
Comment