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 Broskie524 · Aug 15, 2014 at 07:08 PM · gunshootreload

Wrote a script for Shooting, reloading and to display the AMMO in a GUIText

This is the script, When ever I start the game It says "Assets/shoot.js(17,22): BCE0018: The name 'ammotext' does not denote a valid type('not found')" I have no Idea what to do >.>

 var sound : AudioClip; //ie_shot_gun-liminalace-770179786 soundClip
  
 var reloadSound: AudioClip; //reload soundClip
  
 var BulletSpeed = 100; //force of bullets being shot
  
 var projectile : Rigidbody; //bullet prefab goes here
  
 var bullets = 30; //amount of bullets per "clip"
  
 var totalBullets = 60; //total amount of bullets we have available
  
 var reloadTime = 3; //time to reload
  
 var reloadAmount = 10;
  
 var ammo : ammotext; //GUI text for our bullet/ammo count
  
 function Update () {
  
 Fire ();
  
 Reload ();
  
 }
  
 function Fire () {
  
 if(bullets > 0) { //if we have at least 1 bullet then we can fire
  
 if (Input.GetButtonDown("Fire1")) {
  
 var clone : Rigidbody;// Instantiate the projectile at the position and rotation of this transform
  
 clone = Instantiate(projectile, transform.position, transform.rotation);
  
 clone.velocity = transform.TransformDirection (Vector3.forward * BulletSpeed);// Give the cloned object an initial velocity along the current
  
 AudioSource.PlayClipAtPoint(sound, transform.position, 1);                     // object's Z axis
  
 bullets -=1; //subtracts one bullet per fire sequence
  
 }
  
 }
  
 }
  
 function Reload () {
  
 if(bullets < 1) {    //if we have less than 1 bullet then we can reload
  
 if(Input.GetKeyDown("r")) {
  
 AudioSource.PlayClipAtPoint(reloadSound, transform.position, 1); //plays reload soundclip
  
 yield WaitForSeconds(reloadTime); //waits for "reloadTime" before adding bullets
  
 bullets += reloadAmount; //adds 3 bullets to our "clip"
  
 totalBullets -= reloadAmount; //subtracts 3 bullets from our totalBullets amount
  
 }
  
 }
  
 }
  
 function OnGUI () {
  
 ammo.text = "bullets: " + bullets + "/" +  totalBullets.ToString();
  
 }
 
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
Best Answer

Answer by Landern · Aug 15, 2014 at 07:09 PM

Did you define a class called "ammotext"?

 var ammo : ammotext; //GUI text for our bullet/ammo count

On this line, you are saying the variable "ammo" is of type ammotext. You may find this confusing, did you mean to put:

 var ammo : GUIText; //GUI text for our bullet/ammo count

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 Broskie524 · Aug 15, 2014 at 07:21 PM 0
Share

Thanks man It shoots but wont show the GUIText and wont reload Im going to try to fix it

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

No Reload Script Works 1 Answer

3rd Person Gun Aim 1 Answer

I want to be able to make a good shoot script that actually works. 0 Answers

Troubles With A Shoot Script 1 Answer

Gun script reload problems 3 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