So i have been looking around the forum for an answer but i can’t really quite get the answer i need. what i want to do is change to value of the gravity modifier in my particle systemen. I tried using multiple metods like “GetComponent” but that does not give me the option to choose the gravity modifier option. so i do not really know how i should solve this problem. I hope some you you guys here that are more experienced in this area might have the answer.
Use GetComponent only when you can’t fill object reference field by hand. And here are great learning materials you probably need and will gain from greatly.
Also, make sure you’re programming in Monodevelop and not notepad since mono will help you providing handsome amount of hints vital for learning all this stuff.
//C#
public ParticleSystem particleSystemComponent = null;
public float gravity = 2f;
void Awake () {
if( particleSystemComponent==null ){
Debug.LogError( "Oh noes! You forgot to fill particleSystemComponent field in inspector here" );
Debug.Break();
return;
}
particleSystemComponent.gravityModifier = gravity;
}