Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Not Able to see Joystick & Button after deploying game to Android Device

Discussion in 'Editor & General Support' started by Rohit-Joshi, Jul 13, 2017.

  1. Rohit-Joshi

    Rohit-Joshi

    Joined:
    Apr 2, 2015
    Posts:
    15
    Hi,

    I've created a simple Survival Shooter game. I want to deploy it to android. So I've CrossPlatformInput standard package and added Joystick & a button.

    After hitting play button in Unity, the joystick is working fine. Though I'm yet to add functionality to my Fire button, but when I deploy the game to my android device, Neither joystick or Fire button is visible on screen.

    Here is the screenshot of my Unity:

    Here is my android device screenshot:

    Please find link for my project below: https://drive.google.com/open?id=0B9ekxav_JxVsTU5jcjFQQ0ttZlE

    Need to know what's wrong....

    Thanks,
    Rohit
     
  2. julian_cruz

    julian_cruz

    Unity Technologies

    Joined:
    Nov 21, 2016
    Posts:
    16
    Hi Rohit,

    > Need to know what's wrong....

    I was checking your project and my findings were the following:

    • According to your Build Settings, the first scene which is being loaded is the Level 01 5.x scene; I have opened that scene and I figured out that you have forgotten to put the MobileSingleStickControl prefab in the hierarchy, this is the reason why on the device the input controller cannot be shown, because it does not exist in the scene mentioned before.
    Fix number 1.
    Put MobileSingleStickControl into the hierarchy and deploy your build into your device and check again.
    Take a look at the manual in the section Scenes in Build
    https://docs.unity3d.com/Manual/BuildSettings.html

    • I saw your second scene Level 01 which I assumed that is the scene that you are expecting load on the device as the first scene; this scene contains MobileSingleStickControl prefab in the hierarchy. having said that I will describe the second option to fix this, performing the following steps.
    Fix Number 2.
    You could disable the Level 01 5.x scene as you can see in the attached image, also you could order your scenes setting Level 01 as the first scene in the list, this corrects your problem.

    I've attached a zip called images describing the problem and the suggested solutions.
    Please let me know if you need any further help regarding this.

    Regards,
    Julián Cruz
     

    Attached Files:

  3. Rohit-Joshi

    Rohit-Joshi

    Joined:
    Apr 2, 2015
    Posts:
    15
    Hi Julian,

    Thank you so much for the reply.

    I did the fix 2 as you mentioned and both the joystick and button is getting displayed on Android device now.
    However, I've PlayerShooting script attached to the Fire button and it seems not working. Can you please help to fix that as well?

    Regards,
    Rohit
     
  4. julian_cruz

    julian_cruz

    Unity Technologies

    Joined:
    Nov 21, 2016
    Posts:
    16
    Hi Rohit,

    I've PlayerShooting script attached to the Fire button and it seems not working

    What do you mean with attached to the Fire button?
    Is it a new button that you has set on the canvas similar to Jump button?
    I cannot see it in the current project that you attached.

    If so, you cannot add that just like that, because the method `Shoot ()` in the class is calculating by `Physics.Raycast` where the player is shooting a bullet and the start point to spawn the bullet, then if you are attaching this class to a button, the ray cast is calculated based on the button position and it does not touching any collider to compare the final point for the ray cast. This class is for the character not for the UI.

    Having said that, you might create your own script for the UI button, by attaching that script to the button in the canvas then set public the Shoot function in that class. This way you can call that function from the button to do it.

    You could find more information/tutorials regarding UI here:
    https://unity3d.com/learn/tutorials/topics/user-interface-ui

    The tutorial about raycast can be found here:
    https://unity3d.com/learn/tutorials/topics/physics/raycasting?playlist=17120
     
  5. Rohit-Joshi

    Rohit-Joshi

    Joined:
    Apr 2, 2015
    Posts:
    15
    Hi Julian,

    My bad, I was talking about the Jump Button, though its named as Jump Button, it is supposed to fire bullets when it is pressed. I've added PlayerShooting script in the event trigger, still the player is not shooting the bullets

    upload_2017-8-12_12-25-16.png
     
  6. Rohit-Joshi

    Rohit-Joshi

    Joined:
    Apr 2, 2015
    Posts:
    15
    Got a clue Julian.

    As you mentioned, PlayerShooting.cs is attached to GunBarrelEnd in the Player hierarchy. The script contains following code.

    upload_2017-8-13_19-54-58.png

    But even though when I press JumpButton, still teh bool check is displayed as false in the log, so the Shoot() is not getting called. How do I make the check true when the button is pressed?


    Regards,
    Rohit
     
  7. Rohit-Joshi

    Rohit-Joshi

    Joined:
    Apr 2, 2015
    Posts:
    15
    Let us leave that UI Button battle Julian. I've find out an interesting way to shoot the bullets without pressing fire button.
    Now but the problem is that when I try to hit the bullets to enemy, the enemy is not getting dead. When I checked the PlayerShotting scirpt, the enemyHealth variable is always returning Null even if I hit the bullets to enemy.

    upload_2017-8-26_14-9-45.png


    upload_2017-8-26_14-11-26.png


    Can you please tell me why my enemyHealth is returning Null even though if I hit the enemy?

    Regards,
    Rohit