Note that there are some explanatory texts on larger screens.

plurals
  1. POI'm Getting this error in Unity3D - NullReferenceException: Object reference not set to an instance of an object
    primarykey
    data
    text
    <p>I'm getting an error while developing FPS game in Unity 3D</p> <blockquote> <p><em>NullReferenceException: Object reference not set to an instance of an object Node.OnDrawGizmos () (at Assets/Node.cs:14)</em></p> </blockquote> <p>It working fine earlier but when I added layer to the nodes then I got this error.</p> <p>check out with the complete code</p> <pre><code>using UnityEngine; using System.Collections; using System.Collections.Generic; public class Node : MonoBehaviour { public List&lt;GameObject&gt; neighours = new List&lt;GameObject&gt;(); public float nodeRadius = 50.0f; public LayerMask nodeLayerMask; public LayerMask collisionLayerMask; public GameObject goal; void OnDrawGizmos() { Gizmos.DrawWireCube(transform.position, Vector3.one); foreach(GameObject neighbor in neighbors) { Gizmos.DrawLine(transform.position, neighbor.transform.position); Gizmos.DrawWireSphere(neighbor.transform.position, 0.25f); } if(goal) { GameObject current = gameObject; Stack&lt;GameObject&gt; path = DijkstraAlgorithm.Dijkstra(GameObject.FindGameObjectsWithTag("Node"), gameObject, goal); foreach(GameObject obj in path) { Gizmos.DrawSphere(obj.transform.position, 1.0f); Gizmos.color = Color.green; Gizmos.DrawLine(current.transform.position, obj.transform.position); current = obj; } } } [ContextMenu ("Connect Node to Neighours")] void findNeighours() { neighours.Clear(); Collider[] cols = Physics.OverlapSphere(transform.position, nodeRadius, nodeLayerMask); foreach(Collider node in cols) { if(node.gameObject != gameObject) { } } } </code></pre> <p>}</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload