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 Jun 24, 2014 at 07:12 PM by AlucardJay for the following reason:

Other : Multiple Technical Questions

avatar image
0
Question by Hackerlab · Feb 07, 2013 at 09:04 PM · animationaimodelrpg

Making a first person rpg enemy AI

I'm trying to make a first person rpg style game like skyrim but not nearly as big and I don't know how to make AIs, I don't even know where to start. I know how to put my enemy models into unity but not make them preform their animations I had in Maya. I would like the enemy to walk up to the player and attack them with a sword. Any kind of help would be greatly appreciated.

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

2 Replies

  • Sort: 
avatar image
0

Answer by DeBunked · Feb 07, 2013 at 09:47 PM

No offense but you might want to google a few tutorials or mess around with Unity's demo projects, rather than posting that you don't know how to do the most fundamental tasks such as importing a model.

Nevertheless, here are two links: one to the demo projects, which explain some stuff like assembling prefabs, and one to the first of a series of tutorials which I found really helpful myself.

http://unity3d.com/gallery/demos/demo-projects

https://www.youtube.com/watch?v=QMWhtKjUr10

Comment
Add comment · Show 2 · 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 erik_malkavian · Jun 24, 2014 at 07:06 PM 0
Share

@debunked What a horrible, jack-as* way of answering this obviously delicate question.... No wonder no one wants to ask techies a question.... You get arrogant answers like THIS!!

avatar image AlucardJay · Jun 24, 2014 at 07:14 PM 0
Share
  • http://unitygems.com/ai-introduction/

  • http://unity3d.com/learn/tutorials/projects/s$$anonymous$$lth/enemy-ai

avatar image
0

Answer by Kergal · Feb 07, 2013 at 09:48 PM

Hey Hackerlab - see the problem is ... AI is an incredible large topic. No one can and will give you an out of the box solution for your not really precise ( ;) ) question.

An incredible simplified approach would be to attach a sphere collider to the enemy - which acts as sort of a "perception" radius. As soon as the player enters the collider store the player in a target variable. // create a variable to store the players game object private GameObject target;

 //unity specified function that takes a Collider as input
 void OnTriggerEnter( Collider col ) {

 // whatever just entered the trigger - does it have a tag that says "Player" - if so.. continue
     if(col.transform.CompareTag("Player"){

            // store the gameobject attached to the collider in target.
            target = col.gameObject;
     
     }    
 
 }


now you could simply use LookAt(target.transform.position) - to make your enemy always look at your player and Translate him along its forward direction using Transform.Translate (Vector3.forward) .

something like :

 private float moveSpeed = 5f;
 
 void Update () {
 
    //if we have a target
    if(target != null) {
 
       // face the target
       transform.LookAt(target.transform.position);
 
      //walk towards the target (along the z coordinate) with a speed of moveSpeed per 
      //seconds
      transform.Translate(Vector3.forward*Time.deltaTime*moveSpeed);
 
   }
 
 }

but this approach is terrible - however anything more complicated will definitely big too big for this forum.

I feel you , just like me btw. have more urgent issues to study in programming - more "basic" stuff ;) . I strongly recommend you to not rush things by simply buying an AI - pack of the asset store. You will need to code at least a little bit in order to make things work the way you want to.

In order to learn more about AI - and general programming I recommend Petey's Hack and Slash tutorial series on www.burgzergarcade.com

and especially for the AI Eteeski 's Youtube Channel.

Btw. their might be some typos in the code i provided - it simply works as an example. with that code the enemy will ignore walls or any obstacles - if the player jumps the AI will rotate in weird ways and currently it won't stop and attack the player.... for the sake of it :

create a variable called
private float stopDistance = 2.5f; ( or whatever) and add behind if we have a target command line -> if(Vector3.Distance(transform.position, target.transform.position) >stopDistance)

now the AI should stop 2.5f units away from you. (consider placing the LookAt() command somewhere else now)

to attack you would call some function Attack(); that you would have to specify.... obviously you would want a healthscript on the player /AI as well.. which is another function.. I hope you start to realize how much work you will be facing ...

If you have some more precise questions I will gladly try my best to help you further. But please understand - you won't make it without a lot of reading ;)

Cheers Daniel

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

Follow this Question

Answers Answers and Comments

11 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 avatar image

Related Questions

4 directional animation ai 2d 0 Answers

Transform an object in other 2 Answers

Character Animation won't work with FPS scripts 1 Answer

Animated Billboard or Animated Model? 2 Answers

Animated FBX: Model Rest Position 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