Strange behavor when clone object

Hello, in my code when an enemy die it drop money, so i clone the money bag on the same location of enemy. But to see it i have to change the cam (when i click on inventory the cam change) when i go back to the player cam i see the bag that otherwise is invisible. Any idea why this happens?

It’s difficult to tell without a smaller sample project or a video/gif at least to see what the problem looks like.

Not able to make videos :stuck_out_tongue: never done that.

OBS works quite well as a screen recorder:

Or GIF wise:

Thanks to Allan i have got a video of the problem you can skip the first minute, you see that after killing the enemy there’s nothing on ground and after changing cam a sack is shown on ground.

That looks more like a logic bug than a problem with cloning itself. Some questions to ask yourself when debugging are:

  • What logic is performed when going from inventory to main game?
  • Could that have anything to do with visibility?
  • Is the bag actually being created? How do I check?

Hello, i have made a different check, i had a camera disabled as child in player entity so i killed the goblin, enabled the cam and disabled it again, the bag appared…no code is involved this way. EDIT: also when i enable the other camera the bag became visible, i was guessing if it isn’t related to a bug that make the cloned entity visible just if camera is changed or if coordinates change (enemy movement for example, since the goblin is a cloned entity too)

If you can make a smaller demo project showing this problem, that would be great. It does sound very odd if it happens when you just disable/enable a camera.

I have got it!!! Found the bug! When i told u about the enemy i checked both codes and i noticed that in bag code there wasn’t any addchild app.root.addChild(ITEM) … awww… i almost lost my mind just for that…well at least now you know what cause the misview :smiley:

In these cases where you are creating and removing entities, what I found useful is to write a script which prints out the entire hierarchy in console from Root so you know if something has actually been added/removed.

That’s a good hint…i will do that @steven thanks for your patience and your support