I think I’m going insane. I have it check the tag of the collision for “Ground”. It works in editor, but completely ignores it when I build the game to test it. The OnCollisionEnter works, just not the tag checking.
void OnCollisionEnter(Collision col){ Rigidbody rbdy = gameObject.GetComponent<Rigidbody>(); //declares rigidbody Time.timeScale = 0.1f; if (col.gameObject.tag == "Ground"){ //checks to see if you collided with ground rbdy.velocity = Vector3.zero; //stops all rigidboy movement rbdy.angularVelocity = Vector3.zero; //stops all rigidbody rotations dead = true; //makes you dead } }
The time scale change happens, but not the tag check. I tried moving the timescale change inside the tag check, and it never happened. This works when I run it in editor (so its not like I misspelled the tag), but not when I build the game. I also tried to check name on collision, nope. I though maybe the terrain collider was just being weird, so I tried it on a box, still nope. I have a normal box collider on it, not a trigger, and a default rigidbody.
What the heck is happening? Has this happened to anyone else?