I'm newbie to Unity and attempting to move a prefab's arm up and down on a button click but having some difficulty.
The arm movement works when called from the Update() method without checking for a button click. Here's a sample of the code:
[SerializeField] Transform rightArm;
int iRotationSpeed = 100;
void Update()
{
if (Input.GetButtonUp("Button"))
{
// move the arm up
rightArm.Rotate(Vector3.up * Time.deltaTime * iRotationSpeed, Space.World);
// now, move the arm back down
rightArm.Rotate(Vector3.down * Time.deltaTime * iRotationSpeed, Space.World);
}
}
Currently using Unity 2021 Personal.