• 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 LukaKotar · Jan 30, 2012 at 01:15 PM · stopped

A script stopped working!

I modified the PlayerWeapons script from FPS tutorial to pick up GUI Texture taps. This script worked perfectly fine, even after modification, and just stopped working:

 var fireButton : GUITexture;
 
 function Start () {
     SelectWeapon(0);
 }
 
 function Update(){
 
     for (var evt : Touch in Input.touches) {
 
         var HitTest1 = fireButton.HitTest(evt.position);
 
         if (evt.phase == TouchPhase.Began) {
 
             if(HitTest1){
 
             //do something when button is hit
 
             BroadcastMessage("Fire");
 
             Debug.Log("Shooting");
 
             } 
         }
     } 
 }
 
 function SelectWeapon (index : int) {
     for (var i=0;i<transform.childCount;i++)    {
         // Activate the selected weapon
         if (i == index)
             transform.GetChild(i).gameObject.SetActiveRecursively(true);
         // Deactivate all other weapons
         else
             transform.GetChild(i).gameObject.SetActiveRecursively(false);
     }
 }
Comment
Add comment · Show 2
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 Statement · Jan 30, 2012 at 03:28 PM 0
Share

Do you get any error messages?

avatar image LukaKotar · Feb 03, 2012 at 10:06 AM 0
Share

No. I don't get any.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Bunny83 · Feb 03, 2012 at 12:20 PM

Ok, maybe you should check your "something" a bit closer. This script have to be attached to a Gameobject that has the different weapons as child objects.

Your weapons need another script that react to the "Fire" message.

There's not much more to say about that. We don't see your project, we don't see your other script nor your hierarchy setup.

edit
Btw. "Touch" only works on mobile devices, just in case...

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 LukaKotar · Feb 03, 2012 at 02:29 PM 0
Share

That didn't work. But it's okay, cause I found another way! ;)

avatar image
0

Answer by aliakbo · Jan 30, 2012 at 10:00 PM

are you sure its attached to something?

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 LukaKotar · Feb 01, 2012 at 06:17 AM 0
Share

Yes. I double checked.

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

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Sliding object being stopped by invisible edge 0 Answers

On Android 6.0 and above: When Application.Quit () is called game unforfunately stopped on relaunch. 0 Answers

Builded Game Stopped working 2 Answers

Android game shuts down but doesn't crash on startup 0 Answers

Check if a rigidbody has stopped moving for several frames. 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