OK this one is driving me nuts…
I created a VFX Graph. Dragged the VFX Graph into the game hierarchy, which created a game object. I then made that game object a prefab. I deleted the prefab from the hierarchy.
I created a script that is attached to this prefab. The script looks like this -
public class ParticleEffect : MonoBehavior
{
public VisualEffect vEffect;
private void Awake()
{
vEffect = GetComponent<VisualEffect>();
vEffect.playRate = 800;
}
}
The only thing I am doing with this visual effect is setting the play rate.
Now, I can drag this prefab from the asset window into the game hierarchy and the particle effect works perfectly fine in the scene view. What I can’t do is instantiate that prefab from another script. It gives me this warning -
“The referenced script on this Behaviour (Game Object ‘’) is missing!”
EDIT: It does, in fact, instantiate the object. It just doesn’t spawn any particles. What’s even weirder is that if I click on the game object in the hierarchy during gameplay, the particles will start to function properly. Shouldn’t it start to play right away? I even tried using the Play()
function in code, and it still won’t play until I click on the game object…
What am I doing wrong here? Why do I need to click on the game object that spawns in order to start the particle effect?