Question by
snagarajbhar2018 · May 04, 2020 at 09:55 AM ·
rotation
Rotation of a cube
I have three cubes in my game. player needs to rotate each cube.When correct side of all the three cubes are set, it has to trigger some animation. I have the below code, where I am able to rotate all the three cubes properly. Now I want to call animation when correct side of each cube is set. Could someone please help me in that part of the code.
public class MainCubeRotationScript : MonoBehaviour { public GameObject cube1; public GameObject cube2; public GameObject cube3; //private bool cube1Result; // Start is called before the first frame update void Start() {
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.A))
{
cube1.transform.Rotate(0, 90, 0);
}
else if (Input.GetKeyDown(KeyCode.S))
{
cube2.transform.Rotate(0, 90, 0, Space.Self);
}
else if (Input.GetKeyDown(KeyCode.D))
{
cube3.transform.Rotate(90, 0, 0, Space.Self);
}
}
}
Comment