Hey everyone, this is my first time commenting here and I’m completely new to Unity and only have a little programming experience otherwise, so apologies if I mess up the formatting or something.
I wanted to use the new Input System rather than learning something that may/will become outdated, but I’m wondering if this is one of the bugs that Rick warned about because I have no idea what else it could be - although I used Debug.Log and everything appears to be correct and working, so that doesn’t really seem right either. I went back to one of my previous commits where the lasers work completely fine, and ONLY changed the code to what was changed here, even copy and pasting from the Gitlab reference. I’ve got [SerializeField] InputAction fire; and my OnEnable() and OnDisable(), my lasers set properly, etc. of course.
So this:
void ProcessFiring()
{
if (fire.ReadValue() > 0.5f)
{
ActivateLasers();
}
else
{
DeactivateLasers();
}
}
void ActivateLasers()
{
foreach (GameObject laser in lasers)
{
laser.SetActive(true);
}
}
void DeactivateLasers()
{
foreach (GameObject laser in lasers)
{
laser.SetActive(false);
}
}
works perfectly, but this, with absolutely nothing else in my project changed:
void ProcessFiring()
{
if (fire.ReadValue() > 0.5f)
{
SetLasersActive(true);
}
else
{
SetLasersActive(false);
}
}
void SetLasersActive(bool isActive)
{
foreach (GameObject laser in lasers)
{
var emissionModule = laser.GetComponent<ParticleSystem>().emission;
emissionModule.enabled = isActive;
}
}
does nothing. Well, not nothing. The emission module turns on and off in Play mode, and like I said Debug.Log works fine for both isActive and in ProcessFiring. I even tried compiling a build to make sure it’s not just the Unity preview being weird. Did I change some obscure setting that would make this not work or something? I’m at a total loss, and the only things I can think of to try now are changing the input system back, reinstalling Unity etc. but I want to make sure I really didn’t make some dumb mistake, which I’ve been programming just long enough to know that’s most likely what it is! I hate even asking for help, but I’ve seen how helpful you guys are here, so thank you in advance!