MoD
MoD

Reputation: 634

ARCore TransformableNode sets localPosition to [x=0.0, y=0.0, z=0.0] after dragging

I am creating a multiplayer experience for ARCore. So i want to share the LocalPosition of an TransformableNode that is set to a plane.

So when i am setting my TransformableNode to a ParentNode and then set the LocalPosition, everything is alright and i get with getLocalPosition() the correct localPosition.

If i now drag the node to another point on the plane it seems that the TransformableNode lost its ParentNode. Because after dragging the node i get with getLocalPosition() -> [x=0.0, y=0.0, z=0.0] and not the Postion in relation to the parent i set previously.

myAnchorNode.addChild(myTransformableNode);
myTransformableNode.setLocalPosition(position);
//dragging it at runtime
Vector3 x = myTransformableNode.getLocalPosition(position);
// x = [x=0.0, y=0.0, z=0.0]

Upvotes: 1

Views: 554

Answers (1)

Keith Turkowski
Keith Turkowski

Reputation: 811

I would suggest you use this method instead, to get relative position.

https://docs.unity3d.com/ScriptReference/Transform.InverseTransformPoint.html

ARCore manipulates a lot of objects in its own hierarchy, and is probably causing a conflict.

Upvotes: 1

Related Questions