0
\$\begingroup\$

if i import an item directly unto a bone attachment for some reason it becomes so small it is invisible even tho the bone attachment has a scale of 1 to 1 and was never re-sized

also the rotation is wrong, even the bone attachment has a rotation of 0-0-0 always.

and the items I'm importing are always 0-0-0 and 1-1-1, they have no animation data, no animation player and were never attached to any armor ever.

but if i import the same thing as a child of any other node and then move it under the bone attachment, the size remains normal.

i tried to do that in code for a weapon system, and it always gives me an error saying that the item is already the child of a node and can't be moved.

so is there a way to do it?

\$\endgroup\$
3
  • \$\begingroup\$ I don't understand what you are saying about the rotation. What comes to mind is exporting with y-up. See pbs.twimg.com/media/EmVSW5AW8AAoDD9.jpg \$\endgroup\$
    – Theraot
    Commented Jun 22, 2023 at 14:12
  • \$\begingroup\$ @Theraot it's not an export y up thing.... since the problem only happens when the items are added as children of a bone attachment, importing glb or .tscn any other way in any other place of the game results in perfectly normal rotation and perfeclty normal scale \$\endgroup\$
    – Cei
    Commented Jun 22, 2023 at 14:30
  • \$\begingroup\$ @Theraot also the same thing happens when i try to import a simple cube mesh created directly in godot, resized to 0.01 and wrong rotation \$\endgroup\$
    – Cei
    Commented Jun 22, 2023 at 14:50

1 Answer 1

2
\$\begingroup\$

error saying that the item is already the child of a node and can't be moved

The node can have only one parent. If you added it to a parent already (with add_child), you would have to remove it (with remove_child) to be able to add it to a different one.

For example:

node.get_parent().remove_child(node)
new_parent.add_child(node)

However, keeping the transform is another thing, you would want to save it:

var saved_transform := node.global_transform
node.get_parent().remove_child(node)
new_parent.add_child(node)
node.global_transform = saved_transform

You might be able to discard the scale (and also any shear) instead:

var saved_basis := node.global_transform.basis
node.global_transform.basis = Basis(saved_basis.get_rotation_quat())

The above code should work unless the scale is zero, at which point getting the rotation fails.


if i import an item directly unto a bone attachment for some reason it becomes so small it is invisible even tho the bone attachment has a scale of 1 to 1 and was never re-sized

You must have introduced this scaling. The most common case is that the original character was 100 bigger, so you reduce the size in Godot. If you can make the character model it the correct size before importing it (e.g. in blender) that should prevent this trouble.


On the other hand, if you know the scale, you can compensate for it, for example:

node.global_transform.basis = node.global_transform.basis.scaled(
    Vector3(100.0, 100.0, 100.0)
)

Addendum: If the Basis is all wrong, we could reset that:

node.global_transform.basis = Basis.IDENTITY
\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .