(Here is a video)
https://streamable.com/xdzu6
I'm trying to make a tree fall when it's health is 0. I then add rigidbody and use AddForce to make it fall, but it flies instead. I also tried setting it's mass and drag to some crazy high number with no success.
My Code:
private void Update()
{
if(Health <= 0 && !chopped)
{
Rigidbody _rb = this.gameObject.AddComponent();
_rb.mass = 100;
_rb.drag = 1000000;
_rb.useGravity = true;
_rb.AddForce(Vector3.forward, ForceMode.Impulse);
_rb.constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezePositionZ;
chopped = true;
}
if(chopped)
{
StartCoroutine(RemoveFromScene());
}
}
If anyone has any idea what could be wrong please tell me, it's been driving me crazy.
Thanks.
↧