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 Sep 08, 2013 at 03:43 PM by fafase for the following reason:

Not a question.

avatar image
-1
Question by Alanj2007 · Sep 08, 2013 at 02:36 PM · playerenemy

Player Die When Hit By Enemy

Do you guys know how to make player die (turn to death scene) when player hit by enemy?

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 Bayreuth · Sep 08, 2013 at 03:19 PM 0
Share

do you mean shot or hit?

avatar image Alanj2007 · Sep 08, 2013 at 03:21 PM 0
Share

hit enemy

avatar image Bayreuth · Sep 08, 2013 at 03:26 PM 0
Share

you need to calculate the distance and angle to the player and if the enemy attacks the load the death scene

avatar image Alanj2007 · Sep 08, 2013 at 03:29 PM 0
Share

Do I need to make trigger on enemy or something? Please explain all of it. I'm really noob at program$$anonymous$$g....

avatar image Bayreuth · Sep 08, 2013 at 03:34 PM 0
Share

download the "free fantasy ai example" from the asset store you'll find it in Scripting/AI and then look at the scripts they are very useful

Show more comments

1 Reply

  • Sort: 
avatar image
0

Answer by Superwayne · Sep 08, 2013 at 03:35 PM

You can use the OnCollisionEnter function. For c#:

 void OnCollisionEnter(Collision col){
     if(col.collider.tag == "Enemy"){
         Application.LoadLevel("DeathScene"); //name of your death scene
     }
 }

You just need to create an Enemy tag and tag the enemy object as "Enemy"

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 Alanj2007 · Sep 08, 2013 at 03:38 PM 0
Share

Where should I attach this script with? At Enemy?

avatar image Bayreuth · Sep 08, 2013 at 03:39 PM 0
Share

this wont work correctly if the enemy doesn´t attack

Follow this Question

Answers Answers and Comments

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

Related Questions

How To Make Enemy Chase You? 1 Answer

Deduct health on collision 2 Answers

Adding a counter? 1 Answer

change script so enemy car gets destroyed when collided with player car 0 Answers

How can I check the line of sight to see if the player is visible to the enemy? 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