- Home /
Smoothly rotate while holding
hey, I was wondering.. How would I rotate an object to the left while holding the left button and rotate it to right while holding the right button. Right now I have 2 buttons, left and right and a few event triggers..
public void OnPointerUpRight() { isPressedRight = true; }
 public void OnPointerDownRight()
 {
     isPressedRight = false;
 }
 public void OnPointerDownLeft()
 {
     isPressedLeft = true;
 }
 public void OnPointerUpLeft()
 {
     isPressedLeft = false;
 }
After searching for an hour I could not find a solution, how would I rotate an object while holding a button?
Thanks
Answer by Borr1310 · Jan 28, 2017 at 06:29 PM
Got it myself, didnt know it was that easy
  void Update()
     {
         if(GameController.Instance.isPressedLeft == true)
         {
             transform.Rotate(Vector3.forward * speed);
         }
         if (GameController.Instance.isPressedRight == true)
         {
             transform.Rotate(Vector3.back * speed);
         }
     }
Your answer
 
 
             Follow this Question
Related Questions
Camera Rotation stay behind player and not flip 2 Answers
rotate objests with buttons 2 Answers
Move and Rotate picked up object 0 Answers
Trying to rotate my character to the position of my touch on mobile 1 Answer
Help with refining rotation deciphering the switch and drag. This is for touch and C#. 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                