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 Nourero · Aug 06, 2013 at 08:35 PM · enemybloodsplatter

Enemy bleeding

I need to make my gun understand that if I shoot the wall or ground a bullet mark will appear but if I shoot my enemy a blood splatter will show. How can I make this happen? I have the bullet mark working fine but it still shows on my enemy.

 public GameObject BulletMark;
 
 public GameObject Blood;

 void Shoot(){
     animation.Play();
     audio.Play();
     //Normal Raycast                    //Add a random value to mouse position(r
         ray = Camera.main.ScreenPointToRay(Input.mousePosition+Random.insideUnitSphere*GunRecoil);
         if(Physics.Raycast(ray, out hit, 10)){
             //Declear new GameObject variable
             GameObject BulletHole;
             //Create the shootmark prefab at the hit point
             BulletHole = Instantiate (BulletMark, hit.point+(hit.normal*0.001f), transform.rotation) as GameObject;
             //Rotate the created object at the face of the normal LookAt (hit.point+hit.normal)
             BulletHole.transform.LookAt(hit.point+hit.normal);
             BulletHole.transform.parent=hit.transform;
             hit.transform.gameObject.SendMessage("Hit", 5, SendMessageOptions.DontRequireReceiver);
     
     }
Comment
Add comment · Show 1
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 lancer · Aug 07, 2013 at 05:08 PM 0
Share

I would answer, but I don't support these kind of games.

1 Reply

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

Answer by Ejlersen · Aug 06, 2013 at 08:44 PM

You can use layers to do this, e.g. if enemy is in the layer: "Enemy" and wall is in "Wall", then you can check if the hit.transform.gameObject.layer is either enemy or wall.

Example:

 if (hit.transform.gameObject.layer == LayerMask.NameToLayer("Enemy"))
 {
     // Make him bleed!
 }
 else if (hit.transform.gameObject.layer == LayerMask.NameToLayer("Wall"))
 {
     // Make hole
 }
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 Nourero · Aug 06, 2013 at 09:26 PM 0
Share

I am not sure if I understand how to add this line. I am using enemy as layer and wall as layer but I'm not sure how to make this part work.

avatar image Ejlersen · Aug 07, 2013 at 05:06 PM 0
Share

Edited my answer with a small example.

avatar image Nourero · Aug 08, 2013 at 01:00 PM 0
Share

I'm sorry but this did not work. I added the right layer name and everything correct but I got an error message saying something is wrong with this specific line making none of them to show.

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

16 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

Related Questions

How to make my enemy bleed 1 Answer

Blood splatter when shot? 0 Answers

How do I use particles to make blood spurt from an enemy when you shoot it? 1 Answer

Machine gun help 1 Answer

How To Ignore Specific Collider? - Blood Splatter 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