- Home /
collision 2D not working on android device
hello everyone i'm working on a 2D android shooting game with unity 5.4 now to display some buttons that means that the game is over, i used OnCollisionEnter2D to detect if the bullet collides with a gameobject and then set the button canvas to active and timescale to 0 to stope the game
here is the code i used :
void OnCollisionEnter2D(Collision2D col) {
if (col.gameObject.tag == "poop"){
Destroy (col.gameObject);
Time.timeScale = 0;
foreach ( Canvas button in buttons )
{
button.gameObject.SetActive (true);
}
}
}
the probleme is that this works fine in the emulator but when i build the apk and install in my android device, it does not work
any help, please ???!!!`enter code here`
"does not work" is not a helpful problem description. What did you expect to happen? What actually happened?
the idea is when the 2 object collide this will set some buttons to active, in fact is the game over lenu when they collide the game stops and the menu take place
so in unity emulator, it works but in device it does not, i see it colliding but the menu does not appear
thank you
The menu does not appear..... but the colliding gameobject gets destroyed and the timescale gets set to 0, right? So where do you assign the buttons array? Why do you set timescale to 0 anyway? There are a ton of problems I see with people trying to use that, since it stops the game update loop from running.
no the gameobject does not get destroyed and the time scale dont doesnt change but in the device i see the gameobject collide with the other game object because i see the gameobject stops moving
i forgot to mention this
i added : " public Canvas[] buttons; "
I think you need to re-assess what you are doing when you have a Canvas Array.
what do you mean by re-assess, i'm sorry i'm new to coding thank you
i'm only doing this for android it's working in unity emulator but not in device thank you
Your answer
Follow this Question
Related Questions
Unable to get Player to stay on Moving Platform, Collision not being detected. 0 Answers
Bullets go through collider even with continuous collision detection! 0 Answers
Unity2D: How to make my player not walk through walls? 1 Answer
collisions does not get detected every time 0 Answers
Ensure a bullet only hits one enemy 1 Answer