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 Tracey P · Mar 08, 2011 at 02:00 AM · projectileweapon

how to make hud with weapon script?

Im trying to make a weapon script that combines my hud script with the weapon projectile/ammo script so that with each weapon you pick up there is a different hud to see. Like when you pick up a pistol and it shows a blue hud with bullet ammo and a generic cross hare but when you pick up a ray gun it shows a alein cross hair with a bar ammo. I also need help making the gun shoot I got everything setup to decrease ammo and clips but I need help making the thing actually shoot and I am making a mastery system for the gun so I also need help scripting my enemy so that when I kill him it will send a message to this script so that it adds exp to the gun. What I have so far is: var gunHealth : float = 100; private var maxgunHealth : float = 100; private var brokenHealth : float = 30; private var destroyed : float = 0; var broken = false; var unusable = false; var ammo : int = 10; var maxammo : int = 10; private var emptyammo : int = 0; var clipammo : int; private var noclipsammo : int = 0; var empty = false; var reloading = false; var noClips = false; var masteryExp : float = 0; private var leastmasteryExp : float = 0; var maxmasteryExp : float = 100; var levelofMastery : int = 1; var maxlevelofmastery : int = 10; var master = false; var damage : int = 5.5; function Start(){ //need to add the reloading animation animation["trigger"].wrapMode = WrapMode.Once; animation["trigger"].layer = 1; animation.Stop(); }

function Update (){

if (Input.GetMouseButtonUp(0))
animation.Play("trigger");
if (Input.GetMouseButtonUp(0))
gunHealth -= .5;
if (Input.GetMouseButtonUp(0))
ammo -= 1;
if (gunHealth <= brokenHealth){
    broken = true;
}
if (gunHealth <= destroyed){
    unusable = true;
    gunHealth = destroyed;
}
if (gunHealth >= maxgunHealth){
gunHealth = maxgunHealth;
}
if (ammo >= maxammo){
ammo = maxammo;
}
if (ammo <= emptyammo){
ammo = emptyammo;
empty = true;
clipammo -= 1;
}
if (clipammo <= noclipsammo){
clipammo = noclipsammo;
noClips = true;
}
if (masteryExp <= leastmasteryExp){
masteryExp = leastmasteryExp;
}
if (masteryExp >= maxmasteryExp){
levelofMastery += 1;
masteryExp = 0;
}
if (levelofMastery >= maxlevelofmastery){
levelofMastery = maxlevelofmastery;
masteryExp = 100;
master = true;
}

}

function LateUpdate(){ if (broken){ Debug.Log("item is now broken. Get repaired soon"); //I need a GUI message here also that says what is said above. } if (unusable){ Debug.Log("item is now unusable"); Destroy(gameObject); //this is where I need the GUI message to go } if (empty){ Debug.Log("start reloading"); reloading = true; } if (reloading){ Debug.Log("reloading now"); ammo = 10; empty = false; reloading = false; } if (noClips){ Debug.Log("no more ammo available"); ammo = 0; //I need the gun shooting script to stop and I need it to play a clicking sound here when they try and shoot } if (master){ Debug.Log("you are now a master with this weapon"); damage = 35; }

} All scripting done by me :D Im grasping the whole scripting thing so if someone could help me fill in the holes and get this weapon script going so that I could apply it to my different weapons. Thank you

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

0 Replies

· Add your reply
  • Sort: 

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

Slow automatic shooting script? 2 Answers

unlocking weapon (fps) 1 Answer

Shooting Script Bullet Doesnt Fire 2 Answers

Could you advice me why this Gun and Ballistic Script doesn't work? 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