- Home /
How can i fix weird physics bug/glitch ?
i have stange bug with physics , when unfreezing parented rigidbodies . i have made a video .
my code for chopping down trees and unfreezing rigidbodies :
using UnityEngine;
using System.Collections;
public class CHOPCHOP : MonoBehaviour {
public Rigidbody body;
public Rigidbody[] crystals;
// Use this for initialization
void Start() {
foreach(Rigidbody crystal in crystals) {
crystal.constraints = RigidbodyConstraints.FreezeAll;
}
}
// Update is called once per frame
void FixedUpdate() {
if (Input.GetKey(KeyCode.T)) {
body.AddForce(Vector3.forward * 5);
foreach(Rigidbody crystal in crystals) {
crystal.constraints = RigidbodyConstraints.None;
}
}
}
}
Comment
Answer by 2Mtech ADMIN · Aug 17, 2015 at 09:25 PM
delete the rigid body from the tree crystals and add it again with a little less gravity, see if that changes anything, if you don't want the tree rolling remove the rigid body from it, but keep the box collider