Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by TexByte · Aug 26, 2016 at 08:58 AM · android buildnot workingscript error

Scripts works on PC, not android.

Alright so I have a bowling script, that partially works on Android. By partially I mean some scripts work, while others don't at all. However when using PC it works fine.

Here is the code to the NON working scripts:

 using UnityEngine;
 using System.Collections;
 using System.Collections.Generic;
 
 public class ScoreKeeper : MonoBehaviour {
     
     public List<BowlingFrame> Frames = new List<BowlingFrame>();
     
     public int _Frame;
     public int _Down;
     public int _FrameBall = 0;
     public int _Score;
     
     
     
     
     HashSet<int> DownPins = new HashSet<int>();
     
     
     // Use this for initialization
     void Start () {
         DownPins.Clear();
         Frames.Add(new BowlingFrame(0));
     }
     
     // Update is called once per frame
     void Update () {
         
     }
     
     
     
     int getDownPins()
     {
         // there's a bug here..
         int down = 0;
         foreach ( GameObject g in GameObject.FindGameObjectsWithTag("pin"))
         {
             // this means the pin isn't moving
             if (g.GetComponent<Rigidbody>().velocity.magnitude < .1f)
             {
                 Matrix4x4 m = g.transform.localToWorldMatrix;
                 Vector3 uv = m.MultiplyVector(Vector3.up).normalized;
                 // this means it's not pointing upwards
                 if (uv.y < .707)
                 {                
                         down +=1 ;
                 }
                 continue;
             }
         
             if (g.transform.position.y < 0 || g.transform.position.z > 1 || g.transform.position.z < -1)
             {
                 down +=1 ;    
                 continue;
             }
         }
         return down;
     }
 
     
     public void UpdateScore(object ball)
     {
         _Down = getDownPins();
         BowlingFrame bf = Frames[Frames.Count-1].AddScore(_FrameBall, _Down);
         _FrameBall += 1;
         if (bf != null)
         {
             Frames.Add(bf);
             NewFrame();
         }
         
         
     }
     
     public void NewFrame()
     {
         _FrameBall = 0;
         _Frame  = Frames.Count;
         DownPins.Clear();
         Debug.Log("Starting frame " + _Frame.ToString());
         gameObject.SendMessage("ResetFrame", SendMessageOptions.RequireReceiver);
         _Score = BowlingFrame.Score(Frames);
     }
     
 }
 
 
 public class BowlingFrame
 {
     int Score1 = 0;
     int Score2 = 0;
     int Carry;
     public BowlingFrame (int carries)
     {
         Carry = carries;
     }
     
 
     public BowlingFrame AddScore(int ball, int score)
     {
         if (ball == 0)
         {
             Score1 = Mathf.Max (score,0);
             if (score == 10)
             {
                 return new BowlingFrame(2);
             }
             return null;
         }
         else
         {
             // we're still passing in the count of down pins
             // so subtract score 1...
             Score2 = score - Score1;
             if (Score1 + Score2 == 10)
                 return new BowlingFrame(1);
             return new BowlingFrame(0);
         }
                              
     }
     
     public static int Score (IEnumerable<BowlingFrame> frames)
     {
         int score = 0;
         foreach(BowlingFrame f in frames)
         {
             score += f.Score1;
             score += f.Score2;
             if (f.Carry > 0) score += f.Score1;
             if (f.Carry > 1) score += f.Score2;
         }
         return score;
     }
 }


GUI Displays, Score not updated(Not sure if this script is broken or not)

 using UnityEngine;
 using System.Collections;
 
 public class ScoreDisplay : MonoBehaviour {
     
     
     public ScoreKeeper _ScoreKeeper;
     
     void OnGUI()
     {
         Rect r = new Rect(Screen.width - 320, 10, 300, 20);
         GUI.Box(r, _ScoreKeeper._Score.ToString());        
         Rect s = new Rect(Screen.width - 320, 30, 300, 20);
         string frameball = "Frame: {0}    Ball:{1}";
         
         GUI.Box(s, string.Format(frameball, _ScoreKeeper._Frame, _ScoreKeeper._FrameBall+1));    
 
         Rect q = new Rect(Screen.width - 320, 90, 300, 20);
         GUI.Label(q, "Tap the screen to roll the ball");
 
     }
 }

And last but not least, This does not work either.

 using UnityEngine;
 using System.Collections;
 
 public class ResetPinPosition : MonoBehaviour {
     
     
     public Vector3 _Position;
     public Quaternion _Rotation;
 
     void OnEnable () {
         _Position = gameObject.transform.position;
         _Rotation = gameObject.transform.rotation;
     }
 
     public void ResetPin(object _ball)
     {
         
         gameObject.transform.position  = _Position;
         gameObject.transform.rotation = _Rotation;
         gameObject.GetComponent<Rigidbody>().velocity = Vector3.zero;
         gameObject.GetComponent<Rigidbody>().angularVelocity = Vector3.zero;
         
     }
 }


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

67 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

Related Questions

can't change float value from OnTriggerEnter 1 Answer

Apk build has double size when building with Unity 2021.1.18f1 and build is not installable 0 Answers

AoT lists, and lists which I made with Bolt doesn't work on device, but fine work in Editor. 1 Answer

Animation working in Unity and PC build, but not Android 1 Answer

Android Apk suddenly unable to build Unity 2017 0 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