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 Soul_Raven · Apr 19, 2015 at 10:21 PM · androidunity5mobile devicesenter-car

Script Crashing Game On Android Device (Unity 5)

This is a Car Door Script for i wrote in unity 4.6 version. I upgraded the project to Unity 5 and script works in the editor with unity remote. But when i build it to my phone it crashes the game.

Is there anything in this javaScript that causes my game to crash?

And yes you can use it in your own projects.

 #pragma strict
 
 var playerInVehicle = false;
 var playerInRange = false;
 var Char : GameObject;
 var Car : GameObject;
 var engine : GameObject;
 var Cam1 : GameObject;
 var Cam2 : GameObject;
 var CarCamTarget : Transform;
 var doorTexture : GUITexture;
 var exitDoorTexture : GUITexture;
 var carControls : GameObject;
 var charactersControls : GameObject;
 
 
 function Awake(){
     
     
     engine.GetComponent(Engine).engineOn = false;
     
     
     
     
 }
 
 function Start (){
     
     Cam2.SetActive(false);
     Car.GetComponent(Vehicle).enabled = false;
     
     
     
 }
 function Update (){
     Misc();
 }
 
 function Misc (){
     if (playerInVehicle == true){
         
         ParkingBrakeOff();
     }
     else if (playerInVehicle == false){
         
         ParkingBrakeOn();
     }
     
     
     if (carControls){
         Controls();
     }
 }
 
 function OnTriggerStay(other : Collider){
     
     if (other.tag == "Player"){
         playerInRange = true;
     }
 }
 
 function OnTriggerExit(other : Collider){
     
     if (other.tag == "Player"){
         playerInRange = false;
     }
 }
 
 
 function Controls(){
     
     for (var touch : Touch in Input.touches){
         if (playerInRange == true){
             if(touch.phase == TouchPhase.Began && doorTexture.HitTest (touch.position)){
                 if (playerInVehicle == false){
                     playerInVehicle = true;
                     Char.GetComponent.<Rigidbody>().isKinematic = true;
                     Char.SetActive(false);
                     yield WaitForSeconds(2);
                     Char.transform.parent = gameObject.transform;
                     
                     Char.GetComponent.<Collider>().enabled = false;
                     
                     engine.GetComponent(Engine).engineOn = true;
                     Car.GetComponent(Vehicle).enabled = true;
                     
                     Cam1.SetActive(false);
                     
                     Cam2.SetActive(true);
                     Cam2.GetComponent(SmoothFollow).target = CarCamTarget;
                     
                     charactersControls.SetActive(false);
                     yield WaitForSeconds(2);
                     carControls.SetActive(true);
                     
                     
                 }
             }
             
             else if(touch.phase == TouchPhase.Began && exitDoorTexture.HitTest (touch.position)) {
                 if (playerInVehicle == true && Car.GetComponent(Vehicle).currentSpeed <= 0.5 && Car.GetComponent(Vehicle).currentSpeed >= -0.5){
                     playerInVehicle = false;
                     Car.GetComponent(Vehicle).enabled = false;
                     engine.GetComponent(Engine).engineOn = false;
                     
                     carControls.SetActive(false);
                     yield WaitForSeconds(0.5);
                     charactersControls.SetActive(true);
                     Char.GetComponent.<Rigidbody>().isKinematic = false;
                     Char.GetComponent.<Collider>().enabled = true;            
                     
                     Char.SetActive(true);
                     
                     Char.transform.parent = GameObject.Find("mobileControls").transform;
                     Char.transform.position.y += 0.4;
                     Char.transform.rotation.x = 0.00;
                     Char.transform.rotation.y = Car.transform.rotation.y;
                     Char.transform.rotation.z = 0.00;
                     Char.transform.localScale.x = 0.8704561;
                     Char.transform.localScale.y = 0.8704561;
                     Char.transform.localScale.z = 0.8704561;
                     
                     Cam1.SetActive(true);
                     
                     Cam2.SetActive(false);
                     
                 }
             }
         }
     }
     
     
 }
 
 function ParkingBrakeOn(){
     Car.GetComponent(Vehicle).wheelfl.brakeTorque = 500;
     Car.GetComponent(Vehicle).wheelfr.brakeTorque = 500;
     Car.GetComponent(Vehicle).wheelrl.brakeTorque = 500;
     Car.GetComponent(Vehicle).wheelrr.brakeTorque = 500;
 }
 function ParkingBrakeOff(){
     Car.GetComponent(Vehicle).wheelfl.brakeTorque = 0;
     Car.GetComponent(Vehicle).wheelfr.brakeTorque = 0;
     Car.GetComponent(Vehicle).wheelrl.brakeTorque = 0;
     Car.GetComponent(Vehicle).wheelrr.brakeTorque = 0;
 }

 
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

2 People are following this question.

avatar image avatar image

Related Questions

Unity5.4.0p4 compile error for android by il2cpp 1 Answer

Image appears clear on Iphone and strange on Android devices 0 Answers

Failure [INSTALL_FAILED_CPU_ABI_INCOMPATIBLE] (solved) 1 Answer

Is Build and Run essential to make a Gear VR app ? 1 Answer

Help with the new Mobile Notification System in Unity 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