,Know if the mouse position has changed
I am doing a game about a spaceship that rotates around the center of the world using the method rotate around and the angle that it uses to rotate is the distance between the initial click mouse position and the X position of the mouse after it was clicked and when you release the mouse button it stops rotating, but I would like to know how to know when the mouse is not moving when I am clicking the mouse, because I don't want the space ship to rotate when the mouse is not moving when I am clicking the mouse button. this is my code but it is not working.
if (Input.GetMouseButtonDown(0))
{
isRotating = true;
posX = Input.mousePosition.x - (Screen.width / 2);
}
if (isRotating == true)
{
float MousePos = Input.mousePosition.x - (Screen.width / 2);
float distance = posX - MousePos;
if (distance > 1f)
{
transform.RotateAround(Vector3.zero, Vector3.forward, distance * Time.deltaTime);
Debug.Log("rotating");
}
}
if (Input.GetMouseButtonUp(0))
{
isRotating = false;
}
Your answer
Follow this Question
Related Questions
Input.mousePosition doesnt work 0 Answers
Issue with dragging 2D objects diagonally 0 Answers
What is wrong with this simple code? 1 Answer
OnMouseDrag() stopped working after few clicks 0 Answers
Disable current drag of UI.Slider 2 Answers