Rotate 2D ball based on Touch Input
Hi All,
I am trying to get my player to rotate based on pressing touch button (Left button or Right button),
At the moment i have the below, this allows me to rotate the player but only every click, i need the player to rotate while pressing the button down and stop if not pressing button down anymore.
i am in the middle of changing the below script myself but i am at work at the moment so i thought i would post this here and ask.
}
public void StartMoving(float horizonalInput)
{
hInput = horizonalInput;
}
public void RotateL(float rotate)
{
if (Input.touchCount > 0)
transform.Rotate(0, 0, -100* -Time.deltaTime); //Player rotates but on each press / need player to rotate on holding LButton down.
}
public void RotateR(float rotate)
{
transform.Rotate(0, 0, 100* -Time.deltaTime);
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612084214im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How can I move 2d sprites on android? 0 Answers
2D ball rolling animation 0 Answers
rotation problems 0 Answers
How do I rotate a 2d Object to face another object? 3 Answers
Align an object rotation in relation to another object 0 Answers