A observe as much as this matter Node hooked up with Inflexible Physique is displaced when the sport is resized
I adopted the recommendation and created an extra renderRoot2D and digicam to carry all physics associated objects.
With this method the problem of gameObject being displaced on resize is mounted.
However the debugDraw will get fully offset when resized. I’ve hooked up screenshots for reference.
Moreover, I’ve hooked up a zipper file containing the undertaking.
physicsDebug.zip (1.9 MB)
I’ve a sense that this occurs as a result of debugDraw is hooked up to canvas digicam as a substitute of root digicam.
Please take a look and let me know what could possibly be going fallacious.
Would actually admire the assistance.
why you utilize feeling? you may debug it and discover what going fallacious by your self, really feel straightforward to debug it.
I adopted your steps and altered the dad or mum of PHYSICS_2D_DEBUG_DRAW node from canvas to root utilizing the next technique.
this.node.on(NodeEventType.CHILD_ADDED, (node: Node) => {
console.warn("node", node);
if (node.title === 'PHYSICS_2D_DEBUG_DRAW') {
const rootNode = discover('root');
rootNode.addChild(node);
}
});
However nonetheless the DEBUG_DRAW doesn’t align on resize. Any concept why?
You have to modify the orthoheight of the digicam on the foundation node.
When the canvas measurement adjustments, it would mechanically adapt to the digicam configuration on the canvas and won’t modify the root-node’s digicam.
Sadly this doesn’t resolve the problem if utilizing simply fitWidth or fitHeight alone. If each are enabled it really works nicely.
There appears to be some subject with altering the layer property of the Debug Draw node.
It’s set to Layer.Enum.UI_2D when it’s being created in physics-world.ts
I attempted setting it to Layer.Enum.Default which is Layering of the root node.
However it doesn’t change.
As you may see within the screenshot shared. Worth of Default is 1073741824. Whereas UI_2D is 33554432.
Please recommendation on how I can go about altering the layer property.
I’m unsure if the issue is due to this. I don’t know a lot about hideFlags.
node.hideFlags |= CCObject.Flags.DontSave;
I examined it and it really works fantastic, isn’t that what you need?
I tend to change fitWidth & fitHeight as per the facet ratio throughout runtime.
The answer you supplied me works nicely when each fitWidth & fitHeight is ready to true.
Are you able to please uncheck the fitHeight or fitWidth and check out once more.
Right here’s the construct the place I’m making an attempt to alter the layer property of the DebugDraw node.
physicsDebug.zip (2.1 MB)