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
1
Question by williampigmeu · Aug 04, 2012 at 03:58 PM · enemypointflashlight

[solved] Enemy aggressive when point "flashlight" to him

Hi, i'm using a flashlight model with a Directional Light attached to it, and I have a enemy in the game, I need to make this: If I point flashlight to him, it attacks me.

Comment
Add comment · Show 7
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 Chris12345 · Aug 04, 2012 at 04:04 PM 0
Share

you should have a collider in the directional light, and when the enemy enters the light it triggers a event. look at triggers and collision.

avatar image williampigmeu · Aug 04, 2012 at 04:08 PM 0
Share

Can there be any example?

avatar image Chris12345 · Aug 04, 2012 at 04:11 PM 0
Share

yes one moment please.

avatar image Chris12345 · Aug 04, 2012 at 04:17 PM 0
Share

there you go hope that helps you, good luck.

avatar image Chris12345 · Aug 04, 2012 at 04:37 PM 0
Share

Please check my question as answered if this is what you wanted glad to help.

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Chris12345 · Aug 04, 2012 at 04:16 PM

this is an example for you, hope this helps. function React was the message sent to run this first script.

    #pragma strict

    function React () {
    animation.Play("whateveryoucalledyouranimation");
    //or//
    animation.CrossFade ("attackanimation");
   else
   animation.CrossFade ("idleanimation");
    }
     script 2
     this code triggers it.

    #pragma strict
    function OnCollisionEnter(col : Collision) {
    if(col.gameObject.name == "objectcollidenamehere"){
    gameObject.Find("objecttosendmessageto").SendMessage("React");
    }
    }
Comment
Add comment · Show 5 · 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 williampigmeu · Aug 04, 2012 at 04:40 PM 0
Share

Script 1 is attached to camera or Spot Light? (Sorry is Spot Light)

Edit: I don't have a shooting enemy, it's a horror game, attack is: Enemy come to my position walking fast, animate the Attack animation, I take damage.

avatar image Chris12345 · Aug 04, 2012 at 05:04 PM 0
Share

i know this is an example

avatar image Chris12345 · Aug 04, 2012 at 05:05 PM 0
Share

script one is on your character that has the flash light and collider for the character to hit.

avatar image Chris12345 · Aug 04, 2012 at 05:11 PM 0
Share

this should be what you want now.

avatar image Chris12345 · Aug 04, 2012 at 05:25 PM 1
Share

thanks glad i could help.

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

10 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

Related Questions

Make spotlight flicker when seeing enemy? 1 Answer

Problem with Flashlight in Horror Game 2 Answers

Photon Spawn on server, not client 0 Answers

How do I stop a function from executing? 1 Answer

Trap Door Question 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