0 votes

I wan't to get transform of Position3D relative to grandparent, but not global. Currently I am doing this:

func moveNode(node, from, to):
  var temp_transform = node.global_transform
  from.remove_child(node)
  to.add_child(node)
  node.transform = temp_transform

But I need node transform relative to the parent of from and to, not global_transform, since node grandparent is scaled.

In three.js I was doing this in following way:

moveNode(node, from, to) {
  from.updateMatrixWorld();
  to.updateMatrixWorld();
  node.applyMatrix(from.matrixWorld)
  from.remove(piece)
  node.applyMatrix(new THREE.Matrix4().getInverse(to.matrixWorld))
  to.add(piece)
}

But I can't find equivalent of applyMatrix and getInverse in Godot.

in Engine by (16 points)

Why not just use both nodes' global positioning to determine their related positioning? You can just factor in the scaling when comparing them, can't you?

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.