• 2D
  • global transform vs position and rotation problem

If I use this code:

			bullet.position=$muzzle.get_global_position()
			bullet.rotation=rotation

This works fine bullet is correct position, scale, speed, and direction

but if I use this code:

		bullet.transform=$muzzle.get_global_transform()

The bullet now has correct position and rotation, but the scale is much smaller, speed is much slower, and the direction is reversed.

Could some explain why these two dont produce the same results?

There are 3 'components' to a transform: position(translation), rotation and scaling. Your second example copies all 3 while the first example copies only translation and rotation.

If you look at the Transform object, you'll see it has only 2 properties: basis and origin. Origin is a single vector that represents position while basis is a collection of 3 vectors called - you've guessed it - basis vectors.

Orientation of basis vectors represents rotation - or precisely said - orientation of object's local coordinate system. Each basis vector coincides with one of the 3 main axes of object's local coordinate system. Length of a basis vector represents scaling along that axis.

"Rotation" property is extracted from the Transform object by the engine for your convenience. It simply takes basis vectors, normalizes their length and convert their orientation to euler angles.