Advertisement
Lerakelp

Left Turn and Right Turn

Jun 27th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.04 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Player : MonoBehaviour
  6. {
  7.  
  8.     public bool front = true;
  9.      
  10.     public bool back = false;
  11.    
  12.     // Start is called before the first frame update
  13.     void Start()
  14.     {
  15.         front = false;
  16.  
  17.         back = true;
  18.        
  19.         transform.Rotate (0,0,0);
  20.  
  21.        
  22.        
  23.     }
  24.  
  25.     // Update is called once per frame
  26.     void Update()
  27.     {
  28.         if (Input.GetKeyDown(KeyCode.D)) {
  29.  
  30.              
  31.              
  32.              if (front == true)
  33.              {
  34.                  transform.Rotate (0,180,0);
  35.                  front = false;
  36.                  back = true;
  37.              }
  38.            
  39.        
  40.      
  41.     }
  42.  
  43.      if (Input.GetKeyDown(KeyCode.A) )
  44.         {
  45.  
  46.          
  47.  
  48.           if (back == true)
  49.              {
  50.                  transform.Rotate (0,-180,0);
  51.                  back = false;
  52.                  front = true;
  53.              }
  54.              
  55.          }
  56.  
  57.     }
  58.  
  59.      
  60.    
  61.  
  62.    
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement