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 oz m · Jul 24, 2010 at 09:32 PM · aishootmonster

Wandering AI Monster

Hi, I'm making a simple hunting game with an alien theme. The story is you're on an island in an alien world, and you have to hunt to survive. I have a weird alien dog-like monster that has a walk animation. I want it to walk around randomly until it comes close to the player or vice-versa. When that happens I want it to run away until it's twice as far as when it first detects the player. I have no idea how to do this, can anyone help?

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

· Add your reply
  • Sort: 
avatar image
1

Answer by Thom Denick · Jul 24, 2010 at 09:42 PM

Hi there,

Assuming you are making a 3D Game, for the solution to this, I strongly recommend the 3rd person Platformer tutorial provided on the Unity site. It can be found here:

http://unity3d.com/support/resources/tutorials/3d-platform-game.html

If you are well-versed in scripting and the Unity engine, I would go ahead and skip to the chapter on the enemy AI (the chapter titled "Adverseries" Page 69 in my Reader). The robots behave in a manner similar to what you are describing.

If you are completely new to Unity - definitely try some of the easier tutorials, 3D Platformer assumes you are already fairly well-versed in Scripting and the Unity platform.

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 oz m · Jul 24, 2010 at 09:45 PM 0
Share

thanks, i'll check it out, in the mean time, anyone is welcome to continue posting answers

avatar image oz m · Jul 24, 2010 at 09:59 PM 0
Share

It was too complicated, I want it to be way more simple. I don't even want it to attack. I don't have many animations for my monster.

avatar image
0

Answer by oz m · Jul 24, 2010 at 11:07 PM

I made it so if I go close to it, it walks away. I still want it to roam around when I'm not close and it also has a little glitch. If I'm above it on a hill or jumping while I'm close enough, it starts to go down under the terrain. Also if I'm really close to it, it sometimes starts walking in midair. Here's my code:

var person : Transform; var detected : boolean = false; function Update () {

if(Vector3.Distance(person.position,transform.position) <= 30) { detected = true; } else { detected = false; }

if(detected) { var relativePos = person.position - transform.position; relativePos = relativePos * -1; var rotation = Quaternion.LookRotation(relativePos);

 transform.rotation = rotation;
 animation.CrossFade("walk");
 transform.Translate(Vector3.forward * (Time.deltaTime * 2));

} else { animation.CrossFade("idle"); }

}

Can someone please help?

Comment
Add comment · Show 1 · 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 Thom Denick · Jul 25, 2010 at 05:23 PM 0
Share

I think your problem might be that your manually transfor$$anonymous$$g your creature's position, forcing it beyond your collision detection. Try attaching a Character Controller and instructing the Character Controller .$$anonymous$$ove. Again, I think you'll find the bits and pieces you need in that tutorial, definitely worth the four hours or so required to go through the tutorial.

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

1 Person is following this question.

avatar image

Related Questions

Enemy AI monster problem 3 Answers

how to make an enemy Ai blow up when you shoot it? 2 Answers

Monster AI patrol an idle 0 Answers

enemy shoot AI precision 1 Answer

Auto shooting script. 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