- Home /
Multiple issues
Flying AI Planes
Hey Unitarians,
Simple AI question here: How would I go about making planes? I only ask for the basic stuff. I want the plane to be able to target the player (I can handle that myself) I need the plane to always face and move in the direction of the player, and that's easy, but for three things
If the player jet stops moving, I want the enemy plane to stop moving a certain distance away from the player, but continue shooting at the player
I want the jet to avoid the environment
I want the jet to only shoot at the player when it can actually see it, not when the player is protected by a piece of the environment
Does anyone have an idea on how to accomplish this? I don't necessarily need a script just ideas on how to program it. Of course a script in c# would be nice :)
Thanks in advance, Aman Jha
Unity Answers deals with single, specific technical questions. Usually I refer design questions to Unity Forums. But what you have here is multiple specific questions...which have been covered in part or in whole on Unity Answers multiple times. So I'm suggesting you break this question apart, do some research, if you get stuck on a single specific issue, post back with a new quetion on that issue.
Thoughts:
Getting the plane to stop a certain distance away is 'just code' and how you do it will depend on the effect you want. See Vector3.Distance().
Avoiding the environment has been covered many times. There are two basic approaches, raycasting and colliders. That is, you can use an oversized collider to make the plane appear to fly even if it is sliding across the ground. How well colliders works is in part defined by the nature of your terrain. Raycast solutions are typically done for racing games and enemy AIs, so look beyond planes for questions dealing with this subject.
Detecting when one object can see another has also been covered many times. Probably a Physics.Linecast() will be good enough for what I think you are doing, but searching will give your more complex approaches.
P.S. Questions with multiple issues are less likely to get answered since someone would need to know the answer to all of them to provide a complete answer.
Thanks robertbu! Those ideas are great and also, thank you for telling me about only posting one issue on here