• 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 EliteHedgehog56 · Jul 20, 2017 at 06:57 AM · kills

deathmatch point system

for my splitscreen shooter I want the player to be able to score points if they kill another player, at the moment when the players die they drop yellow point cubes, how would I change my player health script to add one point to the killer's killcount?

this is the healthscript I'm using, it's in Javascript

var PointCube : Transform; var spawneffect : Transform; var SpawnPoint : Transform; var respawn : boolean = false; var health:float = 90;

function Damage(dmg:float){ health -= dmg; }

function Update (){ if(health <=0){

Instantiate (PointCube,transform.position,transform.rotation);

transform.position = SpawnPoint.position;

 Instantiate (spawneffect,transform.position,transform.rotation);

var audio: AudioSource = GetComponent.(); audio.Play(); audio.Play(44100);

health += 100; }

}

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by sandeepsmartest · Jul 20, 2017 at 08:01 AM

  void Damage(float Dmg)
     {
         health -= Dmg;
         if(health<=0)
         {
             //instantiation stuff
             //if you are sure about the killer who killed this player
             // increase killer's kill count here simply by taking an instance of the killer script and accessing the value of it 
             //or declare killer script here in your "myplayer.cs" and drag drop the gameobject on which killer script attached and use the reference variable to increase count(killerscript.killcount+=1)
             ////if you are NOT sure about the killer who killed this player
             //pass the player id along with dmg value to this function and based on the player id , increase kill count to the respective player 
             // or pass the gameobject to this method along with dmg and getcomponent killerscirpt from the gameobject that you passed and access the killcount value
             //or simple the killerscript to this method along with dmg access the killcount value
             //Make sure your killerscript conists of the variable killcount with public as accessmodifier
         }
     }

Hope this may help you. -Nsks

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 EliteHedgehog56 · Oct 08, 2017 at 08:45 AM 0
Share

I don't quite understand what you mean

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

68 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

Related Questions

Keeping Score from Kills 0 Answers

Multiplayer Kill Counter? 2 Answers

Custom properties not updating as expected 1 Answer

A [Photon] PvP Script. 0 Answers

My script adds +1 to variable only one time 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