Hello,
I’m experiencing the problem that entities get positioned on the wrong height (too high or too low) when I recalculate the relative height of a node for a simple gravity effect and one of the parent nodes has a different scale than 1f.
I’m doing the relative height calculation like this:
float parentY = parent.absolutePositionCache.y;
position.y = Math.max((terrHeight - parentY), position.y - fallingSpeed);
(terrHeight is the absolute height of the terrain at the current position).
I unfortunately don’t know how to calculate the relative height if the parent node has a scale value. However, if I fake the cached absolute result by assigning absolutePositionCache.y = terrHeight; , it gets rendered as expected. This also is the case if all parent nodes have a scale of 1. This shows me that I retrieve the correct terrain information.
So the remaining question is how to calculate the relative position of a scene node from an absolute target position? At the moment it needs only the y component but I think future coding might need all axis.
Other suggestions how to do this height calculation are also welcome. Sorry if the solution is simple but I currently can’t think of how to consider parent scale in this calculation.