- Home /
Firing Rockets
hi, i have a aircraft with 8 children rockets(no instantiate),pressing fire1 first rocket is launched, if press again Fire1 second rocket is fired, this for the 8 rockets can´t resolve the problem any sugestion of how implement this?
Can you tell us how you shoot them with an animation or whatever?
What's wrong with it? Does it only fire the 1st rocket? Did it work for 1 rocket before you had the array? Do you drag in the rocket children in the Inspector?
The script (which would be better if you could add it to your original question) looks about right.
Answer by Piflik · May 12, 2012 at 09:10 AM
I would add a script with a fire function to the rockets and a second script to the aircraft. In this script I would put all the rockets in an array and fire them by increasing a variable:
var rockets : Transform[] = new Transform[8];
var rockIndex : int = 0;
function Update() {
if(Input.GetMouseButtonUp(0)) {
if(rockIndex < rockets.length) {
rockets[rockIndex].SendMessage("Fire");
rockIndex++;
}
}
}
Your answer
Follow this Question
Related Questions
making the instantiated game object as a child of the GameObject 1 Answer
How To Deactivate A Parent (And Its Children)? 4 Answers
I want to make a animation for a gameobject which have children gameobject! 1 Answer
How is order of children decided? 2 Answers
How can I prevent the children of a prefab from being edited/selected 1 Answer