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