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 PlayerController : MonoBehaviour
- {
- public Transform riffleStartPosition; // ñîçäàåì ïåðåìåííóþ êîòîðàÿ îòâå÷àåò çà ñòàðò âûñòðåëà
- public GameObject bullet;
- private float coolDownShoot = 0.1f;
- private float shootTimer = 0f;
- void Update()
- {
- if (Input.GetMouseButton(0) && shootTimer >= coolDownShoot)
- {
- var bul = Instantiate(bullet, riffleStartPosition.position, riffleStartPosition.rotation);
- bul.GetComponent<Bullet>().SetDirection(transform.forward);
- bul.transform.rotation = transform.rotation;
- shootTimer = 0;
- }
- shootTimer += Time.deltaTime;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement