Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
1
Question by patrick_scheper · Aug 27, 2015 at 12:34 PM · lightingaidetectionsourceai problems

Light detecting + Light lowers variable

Hi there.

I am working in a team for making a game, and there is this problem we have.

We want to have monsters that detect light, when they do detect light they will investigate it. They will be like curious, but the idea is that if they would be exposed to the light, they will slowly die. (there skin would come off and such.)

We thought of a cone collider (for like a flashlight) but we wouldn't know what to do if the player is like inside a house. (collider would collide through the walls..)

Also there would be lamps, spotlights ect, which would all need a collider.

So questions are:

  1. How do you make AI detect light? (Guess with a line of sight?)

  2. How do you let the AI die, when exposed to light?

Thanks a lot!

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

Answer by Barachiel · Aug 28, 2015 at 04:48 AM

I imagine the easiest way, if not the most efficient, would be to have a collider in the shape you want, set it to be a trigger and, in your code, check whatever enters it for an appropriate tag to determine if it's a monster.

To be able to tell if there are walls in between, you could cast a ray from the source of the light to the monster, checking if anything is between the two. There's a lot more to it for a decent set up, but that's the basic direction I'd start in.

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 patrick_scheper · Aug 28, 2015 at 08:20 AM 0
Share

Thank you, I am going to try to use the raycast together with the collider.

avatar image unbelievablename · Aug 28, 2015 at 01:15 PM 0
Share

Will that work for the AI? NPC detection system. kinda that.

avatar image Barachiel · Aug 28, 2015 at 03:21 PM 0
Share

I don't see why it couldn't work with AI as well. Nothing about the solution I suggested involves the player directly, so it's just a matter of implementing it how you'd like.

avatar image
1

Answer by cjdev · Aug 28, 2015 at 02:29 AM

Since there's no practical way of getting the lighting data from the shader itself I would actually use colliders like you suggested. To make sure they don't trigger on other obstacles place them in their own layer with the enemies so they only interact with each other. Then you can use the distance of the enemy collision from the light sources to sum up the total light on the enemy.

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 patrick_scheper · Aug 28, 2015 at 08:20 AM 0
Share

Yeah I think I am going to use a collider and raycast. Thank you very much!

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Use of an AI script, and having it NOT go through walls using a character controller 0 Answers

enemy waypoints and detection scipting 2 Answers

AI detection script problem 0 Answers

Enemy AI, detect player when seen 2 Answers

Resize Array Based on Value 2 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