I have made player and chicken and player can use chicken as weapon and when player dies chicken can move jump and shoot and when i’m getting close to player chicken can drag player and i want to stop it
public void PlayerDamage(float damageAmount)
{
hp -= damageAmount;
UpdateHealthBar();
if (hp <= 0)
{
anim.SetTrigger("die");
_isAlive = false;
// Get the child object (chicken)
Transform chicken = transform.GetChild(1);
chicken.parent = null; // Unparent the chicken first
// Add Rigidbody2D and configure it
Rigidbody2D chickenRb = chicken.gameObject.AddComponent<Rigidbody2D>();
chickenRb.gravityScale = 3; // Set gravity scale
chickenRb.velocity = transform.up * 10; // Apply upward force
// Enable the ChickenScript and BoxCollider2D on the unparented chicken
chicken.GetComponent<ChickenScript>().enabled = true;
chicken.GetComponent<BoxCollider2D>().enabled = true;
}
}