Detach child from parent but keep transform as is

Just guessing here, but perhaps it’s an issue because the barrel that is attached to the player is also a PhysicsBody, which may be calling setPosition on it separately to your own setPosition calls from the player.

As a test, you can try making a fake barrel, like just a sprite or animation which isn’t a PhysicsBody, and use that to attach to the player. You could even simply make it a child of the player in this case, and when the barrel needs to be thrown etc., you hide this fake barrel, and show the actual PhysicsBody version of it in your scene at the same position just before it starts moving on it’s own. The real barrel never has to be associated with the player in any way, it’s just put into the scene when it’s needed for the movement.

You are absolutely correct (again). For a quick test I disabled the barrels physicsBody and it moved perfectly in sync with the player. Now I just have to find a proper solution around this problem.

At least now you have a better idea of what is going on. There should be many different solutions to this problem, and if you’re not sure what’s best, then keep throwing code at it until you’re happy with the result. Don’t be afraid of deleting code and trying something else either. :slight_smile:

Cough, cough. Comment out first. Then delete later? :slight_smile: :slight_smile:

Nah, just delete it. Git has me covered if need it back :wink:

Thanks for your help R101. I’ll mark this as solved :+1:

It was a joke in sorts but I did work at a job a long time ago that we could never delete code. We had to comment out with why, date, time, etc. we never deleted anything. It was frustrating.

I can only imagine what it’s like to work within such a codebase. Must be a mess :face_with_head_bandage:
At my current work we have a lot of empty comments on top of every function because “we need it to generate the documentation”. There’s really a lot of stupidity in coding :grin:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.