I have an object that I want to move it and with click I want to change the rotation of it. I have buttons and if buttons clicked object change color. My problem is when I want to change color object starts moving. How can I fix it.
if (!isMoving)
{
if (Input.GetMouseButton(0))
{
Vector2 ray = Camera.main.ScreenToWorldPoint(Input.mousePosition);
RaycastHit2D hit = Physics2D.Raycast(ray, Vector2.zero);
if (ray.x > ray2.x)
{
transform.Rotate(0, 0, 1f);
}
else if (ray.x < ray2.x)
{
transform.Rotate(0, 0, -1f);
}
ray2 = ray;
}
else if (Input.GetMouseButtonUp(0))
{
myRigidBody.velocity = transform.up * Time.deltaTime * speed;
FindObjectOfType<OkSpawner>().StartOkSpawner();
isMoving = true;
}
}