Search Unity

calling another script not working in built

Discussion in 'Scripting' started by mightyjumpsky, May 25, 2019.

  1. mightyjumpsky

    mightyjumpsky

    Joined:
    Jan 14, 2019
    Posts:
    15
    Hello everyone, can someone help me, my game works perfectly when run in editor and no error but when built in apk is not working.. Supposedly when the player hit the collider, it will launch into the air... I try to debug and fine actually the code for calling another script is not function properly.. Is there any solution I can try... Any help will be much appreciated.... Thank You...


    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class rocketLaunchPlayer : MonoBehaviour
    6. {
    7.     public Transform player;
    8.  
    9.     public GameObject box;
    10.  
    11.     void Start()
    12.     {
    13.         this.player = GameObject.FindWithTag("Player").transform;
    14.     }
    15.  
    16.  
    17.  
    18.     void OnTriggerEnter(Collider other)
    19.     {
    20.  
    21.         if (other.gameObject.tag == "Player")
    22.         {
    23.             Destroy(box);
    24.             player.GetComponent<RocketLaunch>().enabled = true;
    25.  
    26.          
    27.         }
    28.  
    29.     }
    30.  
    31.  
    32.  
    33.     void OnTriggerExit(Collider other)
    34.     {
    35.  
    36.         if (other.gameObject.tag == "Player")
    37.         {        
    38.             player.GetComponent<RocketLaunch>().enabled = false;
    39.         }
    40.  
    41.     }
    42. }
    43.  
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class RocketLaunch : MonoBehaviour
    6. {
    7.     public Transform player;
    8.     public float speed ;
    9.     private Rigidbody rb;
    10.     public float jumpForce = 20f;
    11.  
    12.     Vector3 m_EulerAngleVelocity;
    13.  
    14.     void Start()
    15.     {
    16.  
    17.       rb = GetComponent<Rigidbody>();
    18.  
    19.       m_EulerAngleVelocity = new Vector3(0, 10000, 0);
    20.     }
    21.  
    22.     void FixedUpdate()
    23.     {
    24.        
    25.         rb.velocity = Vector3.up * jumpForce;
    26.  
    27.         rotation();
    28.  
    29.         Vector3 movement = new Vector3(0.0f, 180.0f, 0.0f);
    30.         rb.AddForce(movement * speed);  
    31.        
    32.     }
    33.  
    34.     void rotation()
    35.     {
    36.        Quaternion deltaRotation = Quaternion.Euler(m_EulerAngleVelocity * Time.deltaTime);
    37.        rb.MoveRotation(rb.rotation * deltaRotation);
    38.     }
    39. }
    40.  
     

    Attached Files:

    • 1.png
      1.png
      File size:
      454.6 KB
      Views:
      557
    • 2.png
      2.png
      File size:
      533.1 KB
      Views:
      488
  2. GroZZleR

    GroZZleR

    Joined:
    Feb 1, 2015
    Posts:
    3,201
  3. mightyjumpsky

    mightyjumpsky

    Joined:
    Jan 14, 2019
    Posts:
    15
    Orite Thanks... I've already got the solutions