- Home /
How do I control objects created by a class
Hello, I have a beginner question!
I am designing my own particle system in Unity. So far I have a particle class which defines the particles location, size and age. I also have an emitter class which has a data structure for the particles.
I do not understand how to control game objects that are not already attached to a game object. For example my particle class is defined as:
public class Particle : MonoBehaviour {
public int position,
velocity,
age,
maxAge;
GameObject appearance = GameObject.CreatePrimitive(PrimitiveType.Sphere);
and my emitter class is defined as:
public class Emitter : MonoBehaviour {
//setup data structure to hold particles
Particle[] p_system = new Particle [500];
// Use this for initialization
void Start () {
//initialize all of the particles
for(int i = 0;i < p_system.Length;++i)
p_system[i] = new Particle();
}
On Play, I'm able to spawn 500 spheres, but I do not know how to edit their transforms.
Your answer
![](https://koobas.hobune.stream/wayback/20220613092425im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
What is wrong with this code for adjusting the walls and players to match the screen size? 1 Answer
Is there a point in initiating Transform? Don't all objects automatically have transform? 1 Answer
How do I Update the transform of Instantiate prefab? 2 Answers
Simple particles problem 1 Answer
I am making a 2d game and I want to make it where to can pick up bricks with your mouse 3 Answers