Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This question was closed Sep 23, 2013 at 12:22 PM by Ranger-Ori for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Ranger-Ori · Feb 10, 2013 at 07:48 AM · aiairplaneartificialjetintelligence

Creating an Enemy Jet AI

Hello, I have a question.

I tried to look for resources and information over the internet, and I couldn't find anything useful.

The issue is, that I don't know how to implement my thoughts, I mean, the AI will have a switch case which, he could:

  • Seek/Scan/Normal : The normal state, the jet is flying around.

  • Chase and Shoot: The AI is triggered and trying to kill the player.

  • Flee : The AI will try to shake off the player jet.

I'm trying to think of which of the Unity3D tools I can use to execute my thoughts. The Lerp or Slerp would make a "Un-real" movement if suddenly the enemy jet would turn without physics movement...

Do you have any ideas?

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image $$anonymous$$ · Feb 10, 2013 at 10:09 AM 0
Share

Check out the AI tutorials on unitygems.com, you will even find a finite state machine framework specifically to deal with states nicely.

avatar image Ranger-Ori · Feb 10, 2013 at 03:21 PM 0
Share

Thanks, however, I didn't see anything related to the jet AI, do you think you can give me a more specific link?

1 Reply

  • Sort: 
avatar image
0

Answer by Meater6 · Feb 10, 2013 at 09:52 AM

If you look in the standard assets, there's a script called a character motor. It basically does all the movement, without any AI or input whatsoever. This is what you need for your jet.

Of course, your jets are not bipedal creatures. You will have to make a custom one specifically for an aircraft. This will give the player and the AIs realistic (or at least similar, depending on how well you write it) movement. Then you can make a separate script that deals with the player's input and the enemy AI.

I hope this helps! :)

Comment
Add comment · Show 10 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Ranger-Ori · Feb 10, 2013 at 10:10 AM 0
Share

Thank you for you answer, but I don't think you understood me correctly. I went through the Character $$anonymous$$otor script, and I didn't find anything useful.

I already created the necessary physics movement for the player, I could also use these for the AI jet, however, and this is my problem, No one is controling the AI, I somehow have to make the AI learn by itself how to use his physics to chase or flee.

avatar image Meater6 · Feb 10, 2013 at 10:48 AM 0
Share

I still highly suggest using a "Jet$$anonymous$$otor" script, (created by you of course). Its not necessary, but I think it will make the issue much easier.

Well, I'm assu$$anonymous$$g you know how to do the state machine and the conditions the each state possess.

When the plane is idle: At the start of the game make its target direction in the direction of the way its facing. Then smoothly shift the direction to the left/right. This will give you the basic circling movement.

Chasing/Fleeing: You can use the position the player's jet as the reference point of your AI when chasing and fleeing. When chasing, simply make the target direction the direction of the player. When fleeing, make it the opposite direction of the player.

avatar image Ranger-Ori · Feb 10, 2013 at 03:20 PM 0
Share

Thanks again, So you're saying that I should create a script for a certain target (which is a position, (Vector3)) and just work on a script how the AI will go there. Well, first it does make everything easier to think that way, in a "way points" pattern, then I could make way points for the AI being idle and all the other states.

However, the real question is, how do I implement it with the jet physics? I mean, the player could be in so many positions, and for each position I'll need to create a waypoint for it?

avatar image Meater6 · Feb 12, 2013 at 02:05 PM 1
Share

Calculate the direction the player is in:

 targetDirection = playerPos - tr.position;
 targetDirection = Vector3.Normalized(targetDirection);

That's it. The jet will always follow the character.

avatar image $$anonymous$$ · Feb 13, 2013 at 06:20 PM 1
Share

But you should tell us what you've tried so far, where you are with this... you're expecting people to magically know what you want.. why don't you write the whole thing with that "slerp/lerp" approach and see how it goes... I don't see why that would be "unreal". You can also use SmoothDamp, which is an even more smooth and dynamic function... it doesn't matter if your character is above/left/whatever to the enemy... it can just damp to the desired direction smoothly... I don't see why that would be unrealistic... Well, you can even throw in some randomness in the enemy movement, but that you should do only if a basic follow script is already working....

Show more comments

Follow this Question

Answers Answers and Comments

10 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Artificial Intelligence 1 Answer

BDI Agent Programming in Unity3D 1 Answer

need a logical tip for AI 2 Answers

My model from Blender does not follow the AI script properly! 2 Answers

Tutorials for AngryAnt's Behave 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges