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 GunScript : MonoBehaviour {
- public Object bullet; // префаб кулі
- public Transform aimPoint; // місце вистрілу
- public float reload = 2f; // час перезарядження
- float counter;
- void FixedUpdate() {
- if (counter < reload)
- counter += Time.fixedDeltaTime;
- }
- void Update() {
- if (counter >= reload && Input.GetMouseButtonDown(0)) {
- GameObject go = (GameObject) Instantiate(bullet);
- go.transform.position = aimPoint.position;
- counter = 0f;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement