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 Jan 21, 2013 at 10:21 AM by Fattie for the following reason:

Problem is not reproducible or outdated

avatar image
0
Question by xhybridxreflex · Jan 21, 2013 at 08:06 AM · enemy ai

Enemy AI kills player once it gets really close?

Hey guys,

I have a enemy who already is scripted to follow me but once he gets really close he just goes around in circles. I'm wondering if the enemy could kill the player somehow and then it goes red and say try again or something similar to that.

All I need is a script so when the enemy gets atleast a metre away from the player says that you've died and says try again so then when you click it, it'll restart the game. Please help ASAP!

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 Loius · Jan 21, 2013 at 08:40 AM 0
Share

ASAP? Have you somehow gotten yourself into a contractual obligation to deliver this simple implementation without actually knowing how to do it? /peeve

x)

Hold up, don't set me on fire, I'm writing an answer. :)

avatar image Fattie · Jan 21, 2013 at 10:21 AM 0
Share

All vague questions are immediately closed.

please go to forum.unity3d.com to enjoy a big discussion with your issue, and ASAP scripting for you

1 Reply

  • Sort: 
avatar image
0

Answer by Loius · Jan 21, 2013 at 08:45 AM

Have you seen the scripting reference? It's your friend!

You want OnTriggerEnter or OnCollisionEnter (the first one is called when an object enters a 'trigger volume,' and the second is called when two objects bump into each other) to detect the enemy hitting your player. (I'd recommend a Trigger, since you're concerned with distance rather than actual contact).

Text can be done with either a GUI.Label in the OnGUI function, or with Unity's simple 3D Text object from the Object menu.

Once your enemy hits the trigger, set a boolean to true. While that boolean is true, display the 'try again' screen (either enable the text object, or have the OnGUI function switch to displaying the label). You can use a GUI.Button to listen for the player clicking something, or just listen to Input for a mouse button.

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 xhybridxreflex · Jan 21, 2013 at 10:19 AM 0
Share

You make it sound so easy though, i'm no good at scripting, is there a script?

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

Enemy Combat AI 1 Answer

Enemy AI Script Glitch 0 Answers

RAIN AI motion detection limiting the visual sensor 2 Answers

Implementing a few special attacks for a boss 0 Answers

How to make enemy shoot projectile at player when in range? 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