Question by
ZtekMiniGame · Jan 07, 2018 at 03:33 PM ·
scripting problemerrorunityeditorglitch
Same code in 2 different scripts with different outcomes
I have a script that makes 4 event trigger buttons on my screen tilt towards a platform. In my script only one of my buttons work and each function in the script has an identical concept. I did a test to see why it wasn't working by coping and pasting it into another script and now a different button works and the rest including the one that worked before doesn't. Here is my script:` void Update() {
gameObject.transform.Rotate(side, 0, up);
//Up
if (Up == (true))
{
up = Time.deltaTime * 20;
}
else
{
up = gameObject.transform.rotation.y;
}
//Down
if (Down == (true))
{
up = -Time.deltaTime * 20;
}
else
{
up = gameObject.transform.rotation.y;
}
//Left
if (Left == (true))
{
side = -Time.deltaTime * 20;
}
else
{
side = gameObject.transform.rotation.x;
}
//Right
if (Right == (true))
{
side = Time.deltaTime * 20;
}
else
{
side = gameObject.transform.rotation.x;
}
}
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; }
}`
Comment