i cant figure out when i destroy my last object i cant go to next level or main menu . i want soon as i destroy my last enemy i go to next level. i have 1 more question how i can add sound in my level becoz i dont have that island level . ANY1 PLZ HELP :?:
You could add a script to the camera that has a public variable, say, called NumberOfEnemies. You can set it to the number of enemies you have in your level, and every time one of them dies their script accesses the NumberOfEnemies variable and subtracts 1. You can put that variable in the Update function and check every frame if it is below 1. If it drops to 0 you call the necessary level load functions. Thats just 1 way to do it.
capanno has it right. Rather than set it to the number of enemies in a level, I add one to the count for each enemy I Instantiate. This way I don’t have to count the number of enemies and set a number, and it is right whenever I change the number of enemies.
Start of level for each enemy:
Instantiate (enemy);
enemyCount++;
When an enemy is destroyed:
enemyCount--;
Check for end of level:
if (enemyCount < 1) {
NewLevel ();
}
NewLevel is my own function.
Moonjump isnt that right that when u instanatiate u need to have 3 variables in it (sry i dont know much abt coding i used tornado twins youtube vids i named everythinh what they named)can u tell me whole script.
what i do to keep tracks of stuff, its just to instantiate stuff and then make it child of root gameobjects, for example, all enemies are instantiated and then made childs of a “Enemies” gameobject, and then i simply make a check to the child count of the Enemies gameobject and thats it, if its zero, then no more enemies and you can go to next level
its actually really simple
CoatlGames has a better solution.
abby15bakshi, do some scripting tutorials. A lot of logic problems can be solved that way, and you won’t have to wait for replies here.
thanx for the tip i just got a book java for beginers from library hope i can understand java in 1 month thanx for tha advice guys
Java is not the same as Javascript. There are lots of learning material available on the net.
u mean they are diffrent
:?:
I’m convinced that whoever named JavaScript was evil. Java is actually much closer to C# than JavaScript, and Unity JavaScript actually isn’t JavaScript (most here call it UnityScript)
Confusing, I know, but doing some scripting tutorials should help you a lot.
You can use only one variable for Instantiate. If you don’t specify a position and orientation as your second and third variables then it takes those values from the Prefab.
Abby, please take the time to go though the two Unity tutorials so you can understand Unity better.
You’re doing yourself a disservice by not becoming familiar with how things are done and just copying someone else’s stuff.
Unity makes creating games easy but it’s still not THAT EASY! ![]()
And as mentioned, Javascript is NOT Java, there’s a bunch of free Javascript tutorials on the internet you can start off with…
Good luck and have fun!
-Will
try tornado twins tutorials on youtube
i think its http://youtube.com/tornadotwins
also theres a lot of sites mentioned here
http://forum.unity3d.com/viewtopic.php?t=30633
hope this helps
thank you i did found a script and i hv already seen tornado twins tutorials thanx for advice