- Home /
Best Way To Make A Fighter Jet?
Hello,
I have a load of enemies that are being initiated from a spawn object, and they just walk around the scene.
I want to have the ability to have a fighter jet to come in and drop a bomb.
Let me explain: Right now, I have modelled a jet and place a very simple animation on it - the animation just moves the jet from one side of screen to the other. How can I have the jet fly over a selected enemy, and then drop a bomb?
It's split into two, the first part is getting the jet to find target and essentially play animation on same Vector position (I don't really know what I am talking about) giving the impression that the jet is flying over the target. Then secondly to drop a bomb - this bit is simple I guess, just initiate bomb from jets height that will fall and with impact to floor, create a force explosion.
Possible usages:
LookAt target position?
Track targets x position and play animation along that?
Thanks folks!
Answer by Statement · Dec 10, 2010 at 01:05 AM
How can I have the jet fly over a selected enemy, and then drop a bomb?
Place the jet in an empty game object (let's call it "target") and position the target at the enemys position. Don't move the target after this. Make sure you have animated the jet to fly over 0, 0, 0. Because it is parented to target, it'll fly over the target regardless of where the target is positioned. You can then add an animation event just prior the jet reached 0, 0, 0.
So.
- Make jet animation fly over 0, 0, 0 at some point. Regard this as being over the enemy.
- Make jet animation send an event just before it reaches 0, 0, 0, call it "DropBomb".
- Write "DropBomb" function to drop a bomb from the airplane (Instantiate prefab etc).
- When you want to launch an attack on an enemy, just position target to its location and play the animation.
Do not parent the target to the enemy. Just position it once.
You can also do a prefab with the same setup. Have a root which hold the aircraft. Have the root have a script that can target enemies.
Advantages:
- Simple to make.
- Reusable.
- Probably cuts it for simple things.
- No need for any LookAt hacks.
- No need to constantly update any position.
Drawbacks:
- Harder to hit fast moving enemies.
- Doesn't have any intelligence.
This is probably not the best way to...
I really have a hard time with all the "Best Way To" questions. It is often so domain specific, and often there is no best way to do anything. What is best for you? Do you want something feasible to get done in time or do you want to create a complex AI? So this is "a way to", within the scope of my time spent in unityAnswers and best seen fit to your description. :)
Yeah, you need 1 or 2 scripts. You need a script that drops the bomb. You need a script that places the target and plays the animation.
Please give an update when you're done so we can hear if it worked well!
Your answer
Follow this Question
Related Questions
LookAt mouse, with run animation 1 Answer
Object as far Z as it can 0 Answers
Can I make animations snap to a frame? 1 Answer
Look at object when it is in the range of the player 0 Answers
FBX Animation Import 2 Answers