- Home /
Event System button tilt moving too fast and not working with being pushed down
I have a game where there is a platform and 4 controls on each side of the screen. when you click the buttons the platform will tillt in that direction. So far I have the script that should be working just fine, but when I unhold my button it doesn't stop tilting and when you are holding it it goes way to fast. Here is the script I have so far`public class TiltFile : MonoBehaviour { private int up = 0; private int side = 0;
void Update()
{
gameObject.transform.Rotate(side, 0, up);
//Up
if(Up == true)
{
up++;
}
//Down
if(Down == true)
{
up--;
}
//Left
if (Left == (true))
{
side--;
}
//Right
if(Right == true)
{
side++;
}
}
public bool Up = false;
public bool Down = false;
public bool Left = false;
public bool Right = false;
public void RotateUp() { Up = true; }
public void unRotateUp() { Up = false; }
public void RotateDown() { Down = true; }
public void unRotateDown() { Down = false; }
public void RotateLeft() { Left = true; ; }
public void unRotateLeft() { Left = false; }
public void RotateRight() { Right = true; }
public void unRotateRight() { Right = false; }
} `
Where do you set your variables to false again? , Where did you used your Unrotate[up,down,left,right] method?
I put it on the the pointer up of my event trigger component the ones that set it to true are the pointer down.
Your answer
Follow this Question
Related Questions
Beginner question about using deltaTime 1 Answer
Camera Rotation Script 2 Answers
rotate the object with both fingers at the same time 0 Answers
Time.Delta time inconsistent 0 Answers