RigidBody syncTransform

I want to spawn a wall with a rigid body.
Every wall can have a different length. So i scale the wall along the x-axis.
After i scale (and rotate) it i perform “syncTransform”.

What happens is that every rigid body of previously spawned walls gets updated to the length of the newest wall.

as an example:
spawn wall_1
wall_1 is 3 units long → syncTransform
wall_1 is okay

spawn wall_2
wall_2 is 5 units long → syncTransform
wall_2 is okay
wall_1 looks okay but rigid body is now 5 units long (2 units of invisible wall)

spawn wall_3
wall_3 is 1 unit long → syncTransform
wall_3 is okay
wall_1 and wall_2 still looking okay but have a too short rigid body of 1 inut.

here is the code:

iron.Scene.active.spawnObject('NormWall', null, function(o:Object) {
//position
	o.transform.loc.x = startpoint.x;
	o.transform.loc.y = startpoint.y;
	o.transform.loc.z = startpoint.z;

	//length
	o.transform.scale.x = distance;

	//rotation
	o.transform.rot.fromAxisAngle(new Vec4(0, 0, 1), angle);
	o.transform.buildMatrix();
	o.getTrait(RigidBody).syncTransform();
}, false);


here is an example image of 2 walls created by this code. I marked the rigid body of Wall_1.

is there a way i get an independent rigid body for every wall?

EDIT:
Okay this behavior is only on “mesh” mode:
image

2 Likes

So does setting the rigid-body type to “Box” solve the issue ?

Yes and no.

It solves my issue, because the walls are actually a box-shape
But if someone needs to use and update the mesh type they would get a problem.

I just had to recalculate the psition because its now placed from the center of the object.
I’ll post the new code as soon as i am at home :slight_smile:

But:
Setting from mesh to box solves the problem means that there is something wrong in Armory with the syncTransform of mesh-type Rigidbodies!? maybe a bug? :thinking:
I wanted to look at the functions of syncTransform but i had no time yet.
(It feels like som kind of flipped normal or that one of the verticies doesn’t get updated)
I’ll keep you updated.

1 Like