Advertisement
8ydilnik

move

Sep 18th, 2019
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.95 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class movee : MonoBehaviour
  6. {
  7.     public GameObject Car;
  8.     public int speed1;
  9.     public int speed2;
  10.     public int bonus;
  11.     // Start is called before the first frame update
  12.     public static movee instance;
  13.     void Start()
  14.     {
  15.         if (instance == null)
  16.         {
  17.             instance = this;
  18.         }
  19.     }
  20.  
  21.     // Update is called once per frame
  22.     void Update()
  23.     {
  24.         Car.transform.Translate(0, 0, speed1 * Time.deltaTime);
  25.         Car.transform.Rotate(0, speed2 * Time.deltaTime, 0);
  26.     }
  27.     public void vpered()
  28.     {
  29.         speed1 = 3;
  30.  
  31.     }
  32.  
  33.     public void nazad()
  34.     {
  35.         speed1 = -3;
  36.  
  37.     }
  38.  
  39.     public void left()
  40.     {
  41.         speed2 = -100;
  42.  
  43.     }
  44.  
  45.     public void right()
  46.     {
  47.         speed2 = 100;
  48.  
  49.     }
  50.  
  51.     public void stop()
  52.     {
  53.         speed1 = 0;
  54.         speed2 = 0;
  55.  
  56.     }
  57.  
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement