- Home /
How to make a death-on-collision script for Air Strike Starter Kit?
Hello, everybody!
I was wondering if anybody here familiar with the Air Strike Starter Kit could help me make a death-on-collision script for a game I am developing? When my airplane touches the terrain in the game, it does not blow up and die, but just travels along it like a car. When the enemy planes crash into the terrain, they just stay put and try to fly through it, to no avail. I want the terrain to kill any airplane that comes into contact with it, be it friendly or no.
Thanks!
sethestuff
Answer by smileteam · Sep 03, 2014 at 11:25 AM
I'm sorry, I'm not quite familiar with the AirStrike kit, however I think what you need is this:
function OnCollisionEnter(collision : Collision) {
Destroy (gameObject);
}
You can try writing it in JS and attach it to your planes. (I'm really sorry if this isn't what you needed...)
Thank you so much for your help! The script works perfectly when applied to the airplanes, but I am still trying to figure out how to make the airplanes explode and trigger the game over menu when they crash into the ground. This is something I need to figure out, since I know you are not familiar with the Air Strike Starter $$anonymous$$it. However, the help was fantastic, and I thank you for it!
Thanks!
sethestuff
Aha, You're welcome, The explosion and trigger game over menu should be relatively simple as well.
function OnCollisionEnter(collision : Collision) {
Destroy (gameObject);
Application.LoadLevel("GameOver$$anonymous$$enuNameHere");
}
$$anonymous$$ake sure under build settings in file, you have both your game scene and your game over menu under "scenes in build".
For the explosion, it might help to research particle effects and how to apply them. http://docs.unity3d.com/$$anonymous$$anual/ParticleSystems.html <- This should help.
(Here are a few tips about Unity Answers, 1) When your question is answered, please mark the correct answer as the right one, so people looking for what you've asked knows it's been answered,2) Try to comment on the answer, rather than write an answer if you wish to ask another question regarding your previous question. :P)
Good Luck with your game!
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
RAYCAST KNOWLEDGE HELP!!! 1 Answer
Check if an object is at a relative position? 2 Answers
Changing terrain texture on contact (collision) 2 Answers
Collision I dont understand 1 Answer