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 simpleone · Feb 15, 2011 at 05:05 PM · aitutorials

How to get AI ( Boots )

Hey, I've just finished some of my maps to my game and I've added my own character to the game but I want some enemy boots ( AI ( I got character and animations for the boot's ). It's an fps game so I want them to shoot. Anyone know a good tutorial or can easily tell me here in the forum ? I would love them to be ''Free for All''.

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
Best Answer

Answer by FLASHDENMARK · Feb 15, 2011 at 05:20 PM

I dont know if you can use this. This is a VERY simple AI, it could be a starting point though.

var distance; var target : Transform; var lookAtDistance = 15.0; var attackRange = 10.0; var moveSpeed = 5.0; var damping = 6.0; private var isItAttacking = false;

 function Update () 
 {
 distance = Vector3.Distance(target.position, transform.position);

 if(distance < lookAtDistance)
 {
 isItAttacking = false;
 renderer.material.color = Color.yellow;
 lookAt ();
 }   
 if(distance > lookAtDistance)
 {
 renderer.material.color = Color.green; 
 }
 if(distance < attackRange)
 {
 attack ();
 }
 if(isItAttacking)
 {
 renderer.material.color = Color.red;
 }

}

function lookAt () { var rotation = Quaternion.LookRotation(target.position - transform.position); transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * damping); }

function attack () { isItAttacking = true; renderer.material.color = Color.red;

 transform.Translate(Vector3.forward * moveSpeed *Time.deltaTime);

}

This AI will remain passive until you get close enough. When you get close enough it will look at you. When you get even closer it will run after you until you exit its "attack zone" It wil change color for green to yellow to red when the AI is passive, looking at you and when it attacks you.

Just assign the target you want the AI to follow/Look at in the inspector. This AI can easily be improved.

If you have any questions just ask. :)

Comment
Add comment · Show 3 · 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 Scribe · Feb 15, 2011 at 05:10 PM 0
Share

this might help: http://www.arongranberg.com/unity/a-pathfinding/

it is a pathfinding script which can make your bots move towards your character. you can then add another bit of script to check if the distance from your character to the bot is less than ... then start shoot

avatar image simpleone · Feb 15, 2011 at 06:07 PM 0
Share

Yes, when I added the script to the boot it didn't shoot... and is it possible to make the boots to attack each other ( like free for all ).

avatar image FLASHDENMARK simpleone · Feb 15, 2011 at 06:26 PM 0
Share

if you are talking to me then yes. As I said this is only a basic AI. You can and proberly should "upgrade" it. If you want it to shoot then, use the "Instantiate" function. Hopefully you know what that is and know what it dose. If you dont then you should start out smaller. And yes you can make them attack each other by dragging the character or target you want it to follow or attack, and proberly increase the look at range an attack range.

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

How to Learn AI Scripting 3 Answers

AI Enemies? 1 Answer

Following the next item in an array 0 Answers

AI isn't looping (Javascript) 1 Answer

Steering Overcompesation 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