In my unity2D game run in device so player velocity set not zero when collide with ground.
void OnCollisionEnter2D(Collision2D target)
{
if (target.gameObject.tag=="Ground"){
die();
}
}
void die()
{
if (isAlive) {
isAlive = false;
anim.Play ("BirdDied");
myRigidbody.velocity = Vector2.zero;
playGameVolume.PlayOneShot (diedClip);
}
}
↧