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 /
  • Help Room /
avatar image
0
Question by jure006 · Jul 05, 2016 at 10:40 PM · raycastdestroyhitscore systemcount

How to add score when destroy another player with Raycast?

I making some multiplayer deathmatch game that is playing on the same keyboard shared by 3 players. I want to make some scoring sistem, but i dont know: -How could i check which player have destroyed another player?

In the other words: -How could i check who have sent last raycast before target have been destroyed?

Do you have some idea? :))

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

Answer by Derenger21 · Jul 06, 2016 at 04:38 AM

"same keyboard shared by 3 players" Sounds messy ha ha.

To get a proper answer we'd need to see your code and how attacking one another is set up.

Other than that I, personally, would put a check within the

  if (physics.raycast (me, aim, dist, out Hit){
     hit.takedamage bla bla
     
     if (!Hit.transform.gameObject.activeInHierarchy){
     myScore++;
     }
     }

or

  if (Hit.transform.gameObject.GetComponent<CodeName>().isDead){
     myScore++;
     }
     }

Like I said, hard to answer without more information from you.

Comment
Add comment · 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
0

Answer by jure006 · Jul 07, 2016 at 05:15 PM

Yes, it's messy a bit and it's playing with left hand only ;) , i love it!

That is a code i was looking for but problem is that it doesn't work, actually nothing happen, even Debug.Log not working after i destroy someone.

This is my shooting function code:

void Shoot() { if (CanShoot()) { Ray ray = new Ray(spawn.position, spawn.forward); RaycastHit hit;

         float shootDistance = Random.Range(22, 24);

         if (Physics.Raycast(ray, out hit, shootDistance))
         {
             shootDistance = hit.distance;
             hit.transform.SendMessage("Cmd_ApplyDamage", TheDamage, SendMessageOptions.DontRequireReceiver);
             //hit.transform.SendMessage("BulletRayShoot", TheDamage, SendMessageOptions.DontRequireReceiver);

             if (hit.transform.gameObject.GetComponent<Hunter>().isDead || !hit.transform.gameObject.activeInHierarchy)
             {
                 if(gameObject.transform.parent.name == "Player1")
                 {
                     Debug.Log("Is anybody out there?"); //guess not...
                     HudManager.hudManager.WinNumCountP1++;
                 }
             }
         }

         nextPossibleShootTime = Time.time + secondsBetweenShots;
         GetComponent<AudioSource>().Play();

}

Comment
Add comment · 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

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

80 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 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 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 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 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

Check if position is inside a collider 5 Answers

how do I call a function from another script, when Raycast Hits? 1 Answer

Raycast hit 2 Answers

Highlighting with a Raycast 1 Answer

get array of RaycastAll hits 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