- Home /
Instantiated Object Individual properties through Script
Hello, how do I access an instantiated Objects INDIVIDUAL SCRIPT COMPONENT, for example. I have 2 cars, one is already in the scene when I press play, one gets Instantiated during runtime, I get the script component of the instantiated car and call its SetDrive(true) method when I approach it and hit the space bar. But BOTH CARS ARE NOW DRIVING when im only trying to control one car. How can I work with an Instantiated objects individual properties which are located in the script that is attatched to that particular object? I tried throwing all the instantiated cars inside of a static arry in the car class, but even when I access the component of the car which is at arry index[0]. All cars are moving when I try to drive only the car which I am close to.
Could you please post your code, so we can see exactly what's going on?
for instance, I type CarScriptName.staticArray[0].GetComponent().SetDriveState(true); But this sets all of my instances DriveState() that are in the array and/or not in the array to true as well. Which is undesirable, can anyone please help?
Answer by Kevin 4 · Nov 11, 2010 at 05:47 AM
nvm figured it out, the string driveState in my car script was set to static :-/
Well, mark your answer as the accepted answer, so that the community member won't bump it to the front page in the future.
Your answer
Follow this Question
Related Questions
Instantiated object script properties 1 Answer
InstanceIDtoObject namespace? 1 Answer
How would I set an instance of an object? 1 Answer
object instances 0 Answers
How do I Create 5 Random Racers? 2 Answers