My version was a lot similar to the one Rick had (but I made it before seeing Rick do it so it’s not plagiarism!), but I had a couple of little tweaks:
- Set the death kick direction (or death fling in my case) opposite to the player’s current velocity (times 2) on the X axis (and an exaggerated, fixed amount on the Y axis to make him fly)
- Set the player color to red
I also noticed there’s a bug that if you die on a ladder tile, the gravity stays at 0 and the player flies off into the ceiling, so I fixed that in the Die() method as well.
The code is as follows:
void Die()
{
if (myBoxCollider.IsTouchingLayers(LayerMask.GetMask("Enemy")))
{
isAlive = false;
myAnimator.SetTrigger("Dying");
Vector2 deathFling = new Vector2(-myRigidbody.velocity.x * 2, 50);
myRigidbody.velocity = deathFling;
myRenderer.color = Color.red;
myRigidbody.gravityScale = gravityScaleAtStart;
}
}
Edit: The camera is fine, I just didn’t feel the need to capture the entire game screen for the GIF so it cuts off a bit and focuses on the point at hand.
Edit2: A typo.