C
C#9mo ago
Gingy

2D game in 3D enviroment

having trouble with my code not working properly in unity. first game on my own any help would be greatly appreciated
4 Replies
Gingy
GingyOP9mo ago
The game is detecting collisions when its not supposed to and ending prematurely
AlienMaster 2.0
AlienMaster 2.09mo ago
have you tried flipping the if and else-if statements
if (!(gameObject.CompareTag("Player") && other.CompareTag(scoreObjectTag)))
{
HandleScoreCollision(other.gameObject);
}
else if (!(gameObject.CompareTag("Player") && other.CompareTag(gameOverObjectTag)))
{
Debug.Log("Game Over object collided: " + other.gameObject.name); // Add a debug log for game over collisions
EndGame();
}
if (!(gameObject.CompareTag("Player") && other.CompareTag(scoreObjectTag)))
{
HandleScoreCollision(other.gameObject);
}
else if (!(gameObject.CompareTag("Player") && other.CompareTag(gameOverObjectTag)))
{
Debug.Log("Game Over object collided: " + other.gameObject.name); // Add a debug log for game over collisions
EndGame();
}
And I suggest maybe running some commands to inspect an object's meta-data so try logging the x, y, z location of the object if you haven't already
Gingy
GingyOP9mo ago
i have not tried that and honestly first time being exposed to c# i dont even have a book for my class so i apoligize if i have no idea what you mean
AlienMaster 2.0
AlienMaster 2.09mo ago
No worries get on a discord call
Want results from more Discord servers?
Add your server