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 /
avatar image
0
Question by Aydan · Apr 22, 2011 at 10:12 PM · aienemybulletdodge

making a smart Enemy AI

Hello im making a top down space shooter game and i need a script for a suicide bomber that dodges bullets. heres my script for a normal suicide bomber AI

var victim : Transform; var speed : int = 5; var rotationSpeed : int = 7; var distance : int = 20;

function Update () { var dist = Vector3.Distance(victim.position, transform.position);

 if(dist < distance){
     target = victim;
     transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(target.position - transform.position),rotationSpeed * Time.deltaTime);
     transform.position += transform.forward * speed * Time.deltaTime;
 }

}

the bullet has a tag bullet. how can i make it dodge the bullet

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
-1

Answer by flaviusxvii · Apr 22, 2011 at 10:15 PM

You could add a longer collider to bullets (that extends in their direction of travel) and when the suicide bomber hits that collider they can take some evasive action. It's just a simple example.

The "intelligence" will come from predicting what will happen, and taking action to prevent it.

Comment
Add comment · Show 4 · 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 Aydan · Apr 22, 2011 at 10:36 PM 0
Share

that sounds good but how would I make it evade it when it comes in contact with the new collider

avatar image Joshua · Apr 22, 2011 at 10:44 PM 0
Share

The collider idea sounds impractical. I would go with raycasting. And when the ray collides have the ship steer right/left for a few seconds and then continue.

avatar image Aydan · Apr 22, 2011 at 11:01 PM 0
Share

I dont know much about raycasting so do you know how to do this it would be very helpful thanks

avatar image GesterX · Apr 23, 2011 at 10:42 AM 1
Share

Look in the scripting reference - there are some very clear examples of raycasting. Or try googling "Unity Student" - there is a nice simple ray casting tutorial on there.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

My bullet has no velocity after it is spawned. 1 Answer

How do I apply bullet projectile to enemy ai properly on unity3d 0 Answers

Need help trying to make enemy detect player's projectiles 1 Answer

Smart Suicide Bomber AI 0 Answers

Collsions problem 0 Answers


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