Question by
Fireatwill35 · Feb 08, 2018 at 06:05 AM ·
rigidbody2ddestroygameobjectfreezeposition
[2D] Freezing all constraints also destroys gameobject
My game is a simple 2d drag and flick game. When the ball enters the black hole trigger I want the ball to freeze position. This code is inside the OnTriggerEnter2D attached to the ball.
private void OnTriggerEnter2D(Collider2D col){
if (col.name == "BlackHole"){
rb.constraints = RigidbodyConstraints2D.FreezePosition;
}
}
The object does freeze and then after a second it destroys itself (and I don't see it in the Hierarchy). I troubleshooted ".FreezePositionX" and ".FreezePositionY" and it does work as it should. Then whenever I try ".FreezePosition" or ".FreezeAll" the ball destroys itself after a second or 2. I'm convinced this is a glitch but not sure.
Comment