How to scale up a rigidbody without moving it?

Hi everyone,

I’m working on a game similar to Settlers 2 / 3, but with free 3D graphics and more physics realism. Currently, I’m trying to get the forester and lumberjack done. The forester plants trees, which grow, and get chopped when fully grown by the lumberjack for wood.

My question is about growing trees. For simplicity, a “tree” is currently represented by a simple cylinder, which can grow in size and change color. Each tree has a rigidbody to enable physical interaction. For example, when chopped down, a falling tree may carry down other trees in the process.

I’m experiencing big problems with those bodies when their scale is increased to make them grow. They start moving on their own, pop out of the ground (even when placed directly above it), break hinges which should hold them in place and so on.
I think the problem is that I’m constantly modifying a rigidbody using scale and position to make it grow and stay in place. I know that rigidbodies should be treated with forces only to avoid weird effects.

I’ve searched for solutions for days, but didn’t find any. I thought about not modifying the rigidbodies at all but adding more and more to simulate growth, but this approach has problems, too.

Is there any way to grow a rigidbody in size which is resting on a surface in place?

These are the two lines of code which I currently use to make the “trees” (primitive cylinders) grow:

transform.localScale *= GrowthSpeed;
transform.position = new Vector3 (transform.position.x, transform.localScale.y, transform.position.z);

I haven’t got a huge experience working with rigidbodies, but the first thing that springs to mind is that you could add the rigidbody once the tree is being cut down (and will therefore start falling over).

As you only need 1 rigidbody between two objects colliding for the collision to be registered, you could simply then create rigidbodies on other trees that the first tree collides with within OnCollisionEnter (and recurse naturally).

Not much of an answer, but I hope this helps.

First make the uncut trees rigidbody Kinematic, this make it not respond to physics, then when you cut it down change to isKinematic to false