Search Unity

The variable obj_Bullet of PlayerShooting has not been assigned. How the problem is solved?

Discussion in 'Scripting' started by cekorinka, Jun 13, 2019.

  1. cekorinka

    cekorinka

    Joined:
    Jun 12, 2019
    Posts:
    13
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class PlayerShooting : MonoBehaviour
    6. {
    7.     public GameObject object_Bullet;
    8.     public float time_Bullet_Spawn = 0.3f;
    9.     [HideInInspector]
    10.     public float timer_Shot;
    11.     private void Update()
    12.     {
    13.         if (Time.time > timer_Shot)
    14.         {
    15.             timer_Shot = Time.time + time_Bullet_Spawn;
    16.             Instantiate(object_Bullet, transform.position, Quaternion.identity);
    17.         }
    18.     }
    19. }
    20.  
    bandicam 2019-06-13 17-06-25-897.jpg bandicam 2019-06-13 17-06-25-897.jpg bandicam 2019-06-13 17-06-25-897.jpg
     
  2. LilFire

    LilFire

    Joined:
    Jul 11, 2017
    Posts:
    74
    Where did you put this script?
     
  3. Stardog

    Stardog

    Joined:
    Jun 28, 2010
    Posts:
    1,913
    Click Player in Hierarchy, and put something in the Object_Bullet slot.
     
    EdGunther likes this.