- Home /
Modifying each object in a list, with different modifiers?
So i have a list of objects, and I want each object to move individually.
How would I by as to do this?
Since the For loop seems to want to effect them as a whole.
Why don't you have a script on each objects?
Can you send your code thought?
I wanted to do something along the lines of:
public List<Vector3> posList = new List<Vector3>();
public List<Vector3> curList = new List<Vector3> ();
private List<float> floatList = new List<float>();
private List<Gameobject> objectlist = new List<Gameobject>();
int slot;
foreach(Gameobject obj in objectlist)
{
obj.transform.position = new Vector3(0.0f, curList[slot].y - posList[slot].y, curList[slot].z - posList[slot].z)
slot++;
}
Although, that just makes each one of those objects move one at a time with each update call.
Hmm.. why don't I have each object with it's own script.. I can use something like "Get Component" to attach a script to an object that is instantiated right?
what? no I mean. What are you trying to do? What the point of that script? Because in my opinion, this script is useless, and ins$$anonymous$$d, you should have a script attached to each game object. So each game object will move by themeselves.
Well Im just trying to do what you just said, except all in one script. Basically move each object differently.
And if I do try attaching a script to each object, what would stop them from all moving in the same motion?
What I meant is what is the goal. I need to understand that to help you. Like how are they supposed to move. Do they need to know how the others move? It is just moving from point A to point B ?
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
How do I Create 5 Random Racers? 2 Answers
How to store a class as a variable 1 Answer
Load Objects from a specific directory into a list? 0 Answers
Counting active objects in a list 3 Answers