In my unity 3D project I have an Ground Plane Stage with a child object. While I press an UI-Button the object should rotate, if I release the button, the rotation should stop. Unfortunately it does not work. It only shows me my Debug.Log function but the object does not rotate.
Here is my script:
using System.Collections;
using System.Collections.Generic;
using Unity.Engine;
public class RotateCube : MonoBehaviour
{
public Rigidbody rb;
public rotateStatus = false;
//public float rotationSpeed = 100f;
public void rotateNow()
{
rotateStatus = !rotateStatus;
Debug.Log("Rotation position = " + transform.eulerAngles.y)
}
void Update()
{
if(rotateStatus)
{
rb.transform.Rotate(0, 45, 0, Space.World);
// Also tried it with;
// rb.transform.Rotate(Vector3.up * rotationSpeed * Time.deltaTime);
Debug.Log("Rotation should been happend.");
}
}
}
The script is attached to my gameObject. The UI-Button has an OnClick Event with the gameObject and linked to the rotateNowfunction.
I tried also the Input.GetMouseButtonDown(0) and Input.GetButtonDown() method. Which would work, but with these methods everytime i press the screen my object will rotate.
This is what my console shows if I test it on the iPad:
(Filename: ./Runtime/Export/Debug.bindings.h Line 45)
Rotation should have been happened.
