Question by 
               Slashstep · Jan 27, 2020 at 03:20 AM · 
                rotationscripting problemmovementtransform  
              
 
              Camera Rotation every time a key is pressed
Hey people,
i just started developing with Unity and programming in C# so i don't really have a clue what I made wrong with the following script. I want the camera move and rotate to specific positions and angles every time i press the space bar. Somehow this works only once. What did I made wrong? Thanks for any help.
 private void Update()
 {
     int rc = 0;
     
     if (Input.GetKey(KeyCode.Space) && rc == 0)
     {
         gameObject.transform.localPosition = new Vector3(0, 3, 7);
         gameObject.transform.localRotation = Quaternion.Euler(30, 135, 0);
         rc = 1;
     }
     else if (Input.GetKey(KeyCode.Space) && rc == 1)
     {
         gameObject.transform.localPosition = new Vector3(7, 3, 7);
         gameObject.transform.localRotation = Quaternion.Euler(30, 225, 0);
         rc = 2;
     }
     else if (Input.GetKey(KeyCode.Space) && rc == 2)
     {
         gameObject.transform.localPosition = new Vector3(7, 3, 0);
         gameObject.transform.localRotation = Quaternion.Euler(30, 315, 0);
         rc++;
     }
     else if (Input.GetKeyDown(KeyCode.Space) && rc == 3)
     {
         gameObject.transform.localPosition = new Vector3(7, 3, 7);
         gameObject.transform.localRotation = Quaternion.Euler(30, 225, 0);
         rc = 0;
     }
     return;
 }
 
              
               Comment
              
 
               
              Your answer