I have an array that I have placed 20 scriptable objects inside of (in the inspector not in code). Another script randomizes the array so it is different each time (like shuffling a deck of cards). The problem is that when i try to access the array using the value clicks
(from a different script to the one it was made in) it says there is an error Object reference not set to an instance of an object
.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CardStackClick : MonoBehaviour {
private RandomSequence randArr;
public GameObject cardPrefab;
private int clicks = 0;
public void Clicked ()
{
if (clicks < 20)
{
ScriptableObject activeCard = randArr.array[clicks];
clicks += 1;
cardPrefab.GetComponent<CardDisplay>().card = activeCard as CardStats;
}
}
}