Savelyev_Vyacheslav

Unity3d no-turning RACETS

Jun 6th, 2020
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.82 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Racet : MonoBehaviour
  6. {
  7.     float countshoot2;
  8.     Rigidbody racet;
  9.     // Start is called before the first frame update
  10.     void Start()
  11.     {
  12.        racet = GetComponent<Rigidbody>();
  13.        //  GetComponent<Rigidbody>().velocity = new Vector3(0, 0, 20);
  14.     }
  15.  
  16.     void Update()
  17.     {
  18.         racet = GetComponent<Rigidbody>();
  19.         GetComponent<Rigidbody>().velocity = new Vector3(0, 0, -30);
  20.     }
  21.     void OnTriggerEnter(Collider other)
  22.     {
  23.         countshoot2++;
  24.         print(countshoot2);
  25.         if (countshoot2 > 3)
  26.  
  27.         {
  28.             countshoot2 = 0;
  29.             if (other.tag == "shiptrig")
  30.             Destroy(other.gameObject);
  31.             Destroy(gameObject);
  32.         }
  33.  
  34.     }
  35.  
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment