My code is supposed to spawn either cg or gc but it won’t
Script A
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class arm_lift : MonoBehaviour
{
public int rng;
public Animator animator;
// Start is called before the first frame update
void Start()
{
rng = Random.Range(1, 2);
StartCoroutine(waiter());
}
// Update is called once per frame
IEnumerator waiter()
{
yield return new WaitForSecondsRealtime(Random.Range(1, 3));
animator.SetFloat("arm_up?", 1);
if (rng == 1)
{
BroadcastMessage("cheese");
}
if (rng == 2)
{
BroadcastMessage("grease");
}
StopCoroutine(waiter());
}
}
Broadcast rng
Script B
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class spawn_nomm : MonoBehaviour
{
public GameObject cg;
public GameObject gc;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void update()
{
}
void cheese()
{
Instantiate(gc, transform.position, transform.rotation);
}
void grease()
{
Instantiate(cg, transform.position, transform.rotation);
}
}
This one receives it