Savelyev_Vyacheslav

Unity3d no-turning scriptgub

Jun 6th, 2020
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.17 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class scriptgub : MonoBehaviour
  6. {
  7.     public GameObject laszerShot;
  8.     public GameObject lazerGun;
  9.     public float shotDelay;
  10.     public float speed;
  11.     float nextShotTime;
  12.    
  13.     Rigidbody ship;
  14.     // Start is called before the first frame update
  15.     void Start()
  16.     {
  17.         ship = GetComponent<Rigidbody>();
  18.     }
  19.  
  20.     // Update is called once per frame
  21.     void Update()
  22.     {
  23.         float moveHorizontal = Input.GetAxis("Horizontal");
  24.         float moveVertical = Input.GetAxis("Vertical");
  25.         ship.velocity = new Vector3(moveHorizontal, 0 , moveVertical)*speed;
  26.      
  27.         //без поворота
  28.    
  29.         ship.transform.localRotation = Quaternion.Slerp(ship.transform.rotation,
  30.  Quaternion.Euler(0, 0, 0), speed * Time.deltaTime);
  31.  
  32.         if (Input.touchCount > 0)
  33.         {
  34.             print(Input.touchCount);
  35.         }
  36.  
  37.  
  38.  
  39.         if (Time.time > nextShotTime)
  40.       {
  41.            Instantiate(laszerShot, lazerGun.transform.position, Quaternion.identity);
  42.            nextShotTime = Time.time + shotDelay;
  43.  
  44.  
  45.         }
  46.  
  47.     }
  48.  
  49. }
Advertisement
Add Comment
Please, Sign In to add comment