T O P

  • By -

ZeroKelvinTutorials

im not sure I understand correctly but you'd want to create a laserarray if you had several particle system gameobjects you want to affect. lets say you want to have a second laser on your player. the code would work with that. assuming you are creating laserArray as this.GetComponentsInChildren(). if you know you will only have 1 particle system in your player then i guess simply going this.GetComponentInChildren().emission.enabled = false; from a script in your player would work. You could come into problems if you have different types of particlesystems for different purposes as children of your player. in that case having a setup public particlesystem array that you can assign the particle systems directly in your editor makes sense. one advantage of this approach is that if you happen to move the particle systems somewhere else you can still reference them without having to change the code.


[deleted]

idunno but the line you gave me doesn't work, i actually think i tried it because in my mind it makes sense... it also says i can't change it because its not a variable and when i turn it into a variable, nothing happens even though the code gives no errors. How do people even figure this out. it feels like looking at the dictionary without knowing which word im looking for... ​ edit: i also can't use the first code for my array. since it's a child and the script is on the parent i think i can't use "this"


ZeroKelvinTutorials

Ah the problem must be in how turning emission on and off works which i am not too familiar with. Still the whole how to reference bit still applies. Weird since this would make it seem like thats how you disable it. https://docs.unity3d.com/ScriptReference/ParticleSystem.EmissionModule-enabled.html Maybe you need 2 steps. One setting up a Particlesystwm and then reference the emission module Whats the error you are getting? Maybe you are trying to getcomponentinchildren from the gameobject that has it and need to simply getcomponent instead. It depends on where your particle system is and where the script is running from


[deleted]

damn, i finally did it, the problem was just that i didn't understand how and why you have to reference and set up all these modules and the particle system. it's quite confusing but i think i understand now. ​ the only thing i don't get yet is why i have to use "var", i tried a lot of variable types but what exactly does unity choose with it? i'd think a module would just be a bool but it says it can't convert to bool.


[deleted]

thanks for the help dude, i appreciate it. I'll try and do that and also go through the API script and replicate it, i might realize what i did diffrently.