Advertisement
Guest User

Untitled

a guest
May 21st, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Shooting : MonoBehaviour {
  6.  
  7. private Rigidbody2D Bullet;
  8.  
  9. public float ShootCooldown;
  10. public float CooldownCounter;
  11.  
  12. public bool CanShoot;
  13.  
  14. void Start () {
  15. CanShoot = true;
  16. }
  17.  
  18. void Update () {
  19.  
  20. if (Input.GetKeyDown (KeyCode.Mouse0) && CanShoot) {
  21. GameObject instance = Instantiate(Bullet, transform.position, transform.rotation) as GameObject;
  22. CanShoot = false;
  23. StartCoroutine (CanShootAgain ());
  24. }
  25. }
  26.  
  27. IEnumerator CanShootAgain (){
  28. yield return new WaitForSeconds (1);
  29. CanShoot = true;
  30. }
  31. }
  32.  
  33.  
  34. //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