How to apply script to a imported OBJ file in unity?
I am new to unity
I imported a OBJ model and assigned materials to it
I want to rotate it using mouse in the game
The script is :
using UnityEngine;
public class MouseDragRotate : MonoBehaviour {
float rotationSpeed = 0.2f;
void OnMouseDrag()
{
float XaxisRotation = Input.GetAxis("Mouse X")*rotationSpeed;
float YaxisRotation = Input.GetAxis("Mouse Y")*rotationSpeed;
// select the axis by which you want to rotate the GameObject
transform.RotateAround (Vector3.down, XaxisRotation);
transform.RotateAround (Vector3.right, YaxisRotation);
}
}
Then I tried to apply a script for rotation but add component not found the inspection menu
So i dragged it to the Hierarchy panel
It was re created again
Then I applied materials again
Then I added the rotation script using add component . But when running the game in play mode , I can't rotate it
So I created a cube and plane and applied the script
The script works perfectly for cube and plane but not for imported object
please help me
Your answer
![](https://koobas.hobune.stream/wayback/20220612203523im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How can I add inertia to a rotation when I release the mouse? 1 Answer
Simple Rotate Script won't work! 2 Answers
Player is not flipping 0 Answers
how do i rotate an object? C# 1 Answer
How to rotate a ship using the right analog stick? 0 Answers