Hello,
I was searching the forums but haven’t found quite a solution to the issue I’m experiencing.
It’s in a way similar to the issue with particles: /t/particlesystem-bug-after-change-position/58638
But just with nodes
The most simplified issue reproduce steps:
You have parent and child nodes
You hide/deactivate the child node
You move the parent node
You reveal the child node and it’s at the old position until you move the parent again
Expected result:
When you reveal the child nodes it keeps its relative position to the parent node
The ugly patch might be to move the parent every time I reveal the children, but I expect the engine to take care of handling the position of the child nodes when activated, and it looks like an engine bug which is happening on Cocos 3.X and not on Cocos 2.X
If needed I can make a basic demo project or I can record a video
I found this may be this will help. This is simular in cocos2d-x. Attaching an arrow (sprite) to another sprite (character) in Cocos2d/Cocos2d-x.
Step 1: Create Sprites
auto arrowSprite = Sprite::create(“arrow.png”);
addChild(arrowSprite);
auto characterSprite = Sprite::create(“character.png”);
addChild(characterSprite);
Step 2: Attach the arrow to the character
auto characterPosition = characterSprite->getPosition();
arrowSprite->setPosition(characterPosition);
characterSprite->addChild(arrowSprite);
void update(float delta) {
auto characterPosition = characterSprite->getPosition();
arrowSprite->setPosition(characterPosition);
Thank for the advice but the issue is a bit different:
Again, you have two objects, one is parent of another.
You hide the child objects, you move the parent object, you show back the child object - and instead of being in the new position its still in the old position until you move the parent again.
The engine reports that the child object is in the new position, you can even log it, but it will not update visually the position until something moves.
I believe it to be an engine bug
Unfortunately my rating in this forum is not high enough to upload the video
Hi. Did you solve your problem? My be this can help - try to make the child object transparent, or place it at the lowest Z level under the object that will obscure (hide) your object, which has to be invisible