Edit: I see another post was recently locked
Hello,
In my application I have Node A with given scale (.525f, .42f, .0462f). Node A itself is locally scaled to Vector3.One, but is scaled to that world scale by its own parent in this context. I’d like to attach Node B to Node A as a child. When I set Node B as a child of Node A, its scale is modified by the parent scale, as expected. However, if I use SetWorldScale to force Node B back to its original scale, that doesn’t happen. Instead Node B is scaled to some new set of values seemingly still modified by the parent. This doesn’t seem like expected behavior, am I doing something wrong? I’ve included a detailed snippet below showing the problem. My head is really spinning on this one and I’d greatly appreciate the advice.
Node nodeA = Scene.AddChild();
nodeA.SetWorldScale(new Vector3(3.2f,.2f,.2f);
Node nodeB = Scene.AddChild();
nodeB.SetWorldScale(Vector3.One);
var originalWScale = nodeB.WorldScale;
var originalLScale = nodeB.Scale;
nodeB.ChangeParent(nodeA);
System.Diagnostics.Debug.WriteLine($"Pre Reset: {originalScale} {originalLocalScale} {nodeB.WorldScale} {nodeB.Scale}");
Pre Reset: (0.9999999, 0.9999999, 0.9999999) (1, 1, 1) (0.525, 0.4199999, 0.0462) (1, 1, 1)
this.Node.SetWorldScale(originalScale);
System.Diagnostics.Debug.WriteLine($"Post Reset: {originalScale} {originalLocalScale}{nodeB.WorldScale} {nodeB.Scale});
Post Reset: (0.9999999, 0.9999999, 0.9999999) (1, 1, 1) (0.9999999, 9.090908, 0.11) (1.904762, 21.64502, 2.380952)
I set nodeB’s world scale, which should be unmodified by its place in the hierarchy, to (.999,.999,.999). The very next line, nodeB’s world scale is (0.9999999, 9.090908, 0.11). I’m mystified.
Apologies if this is the wrong forum for this topic. I understand this is primarily Urho3D discussion, but google results for UrhoSharp problems take me here with some regularity and I see UrhoSharp related discussions both being closed as off topic and answered by helpful people. If there’s an alternative place to ask this please let me know.