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.
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
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.
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?
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:
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
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?
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.