Hello! I am having a problem with making an instantiated object work :/. So when I go into my game scene and click play my instantiate function works. But when I go onto the main menu scene and press play and then play button it, it will load into the game but the instantiate function wont work. Here is my problem in video form: UnityGameError - YouTube here is my instantiate function code:
`
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class JumpSpawn : MonoBehaviour
{
public Transform Spawns;
public GameObject Enemy;
public Rigidbody PRig;
private float timetospawn = 0.5f;
void FixedUpdate()
{
if (Time.time == timetospawn)
{
spawnenemy();
timetospawn = timetospawn + 0.5f;
}
}
void spawnenemy()
{
int randomIndex = Random.Range(0, Spawns.Length);
for (int i = 0; i < Spawns.Length; i++)
{
if (randomIndex == i)
{
GameObject clone = Instantiate(Enemy, Spawns*.position, Quaternion.identity);*
}
}
}
}`