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 Ryan Mayer · Feb 01, 2011 at 01:57 AM · turretcounterkill

How to make a Kill Counter

Hey im using a GUI to display how many turrets the player kills but for some reason it wont count up heres the code for the gui:`function Update () { var killCount: int; var globalCounter : GameObject = GameObject.FindWithTag("GlobalVars");

killCount = 0;

if (gameObject.Find("SmallTurret").hit) { 
    globalCounter.killCount += 1;
    print("kill count is now: "+globalCounter.killCount); 
}

}`

and the code i put with the turret:

 var explosion : Transform; 

private static var numKills : int; var killsDisplay : GUIText; if(gameObject.tag == "wormProjectile") { numKills++ ;

killsDisplay.text = "Kills: "+numKills; }

function OnTriggerEnter( hit : Collider )

{ if(hit.gameObject.tag == "wormProjectile")

{ Destroy(hit.gameObject); var exp = Instantiate(explosion, gameObject.transform.position, Quaternion .identity); Destroy(gameObject);

}

Comment
Add comment · Show 3
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 · Feb 01, 2011 at 02:39 AM 1
Share

As Justin has said below, this is pretty bad form. You should try to write your own code first, and then post when you get stuck. If you have very limited knowledge of Unity or Unityscript/Javascript, then you should probably work through a few tutorials, rather than diving into specific questions like this, or you'll be back here asking how to implement every specific mechanic.

avatar image Ryan Mayer · Feb 01, 2011 at 03:12 AM 0
Share

i did try to write my owncode but its failing

avatar image Ryan Mayer · Feb 01, 2011 at 03:13 AM 0
Share

if anyone can help me thatd be great

1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by Justin Warner · Feb 01, 2011 at 02:10 AM

Ooooooooook, please, no one write him a whole script...

Now, for the actual scripting for the kill count, you'll need a health system, or if it's one shot kill, you'll need to have to look at the collider API

http://unity3d.com/support/documentation/ScriptReference/Collider.html

Now, when it hits, you'll need to check out the GUI.

http://unity3d.com/support/documentation/Components/gui-Basics.html

Now, this should cover most of it... Their is also a Destroy() function to make the turret disapear and you can see the instantiate to make a "dead" turrent model appear in its place.

http://unity3d.com/support/documentation/ScriptReference/Object.Instantiate.html

Now, www.Google.com will help with scripting, and now, my fine feathered friend, you're armed to code your own project.

Good luck, and be safe, and PLEASE comment your code if you want people to help 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

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

No one has followed this question yet.

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Kill Counter --> Score 2 Answers

problem with shooting killing script 1 Answer

Array problem -3 Answers

Combat Script 2 Answers


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