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 Shooting : MonoBehaviour {
- private Rigidbody2D Bullet;
- public float ShootCooldown;
- public float CooldownCounter;
- public bool CanShoot;
- void Start () {
- CanShoot = true;
- }
- void Update () {
- if (Input.GetKeyDown (KeyCode.Mouse0) && CanShoot) {
- GameObject instance = Instantiate(Bullet, transform.position, transform.rotation) as GameObject;
- CanShoot = false;
- StartCoroutine (CanShootAgain ());
- }
- }
- IEnumerator CanShootAgain (){
- yield return new WaitForSeconds (1);
- CanShoot = true;
- }
- }
- //Error CS0039: Cannot convert type 'UnityEngine.Rigidbody2D' to 'UnityEngine.GameObject' via a built-in conversion
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement