Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class Vrag : MonoBehaviour
- {
- public GameObject Shot2;
- public GameObject Gun2;
- public float shotDelay2;
- public float speed;
- float nextShotTime2;
- float countshoot2;
- Rigidbody vrag;
- // Start is called before the first frame update
- void Start()
- {
- vrag = GetComponent<Rigidbody>();
- // vrag.velocity = new Vector3(2, 0, 5);
- }
- // Update is called once per frame
- void Update()
- {
- float moveHorizontal = Input.GetAxis("Horizontal");
- float moveVertical = Input.GetAxis("Vertical");
- vrag.velocity = new Vector3(moveHorizontal, 0, 0) * speed;
- //без поворота
- vrag.transform.localRotation = Quaternion.Slerp(vrag.transform.rotation,
- Quaternion.Euler(0, 0, 0), speed * Time.deltaTime);
- // Instantiate(Shot2, Gun2.transform.position, Quaternion.identity);
- if (Time.time > nextShotTime2)
- {
- Instantiate(Shot2, Gun2.transform.position, Quaternion.identity);
- nextShotTime2 = Time.time + shotDelay2;
- }
- }
- void OnTriggerEnter(Collider other)
- {
- countshoot2++;
- print(countshoot2);
- if (countshoot2 > 10)
- {
- countshoot2 = 0;
- if (other.tag == "shiptrig")
- Destroy(other.gameObject);
- Destroy(gameObject);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement