activate/deactivate ghost?

hey!
i was making my game, and i added a invisible cube in the hands of the guy to replace it for a gun later via LibLoad() but i forgot to set it to ghost and when i started the game, something really cool(and weirdly fun) happened, and i would like to add it later as a cheat, but i need to be able to set the cube to ghost/non ghost during the game for that, and i dont know how, i searched the API and couldnt find it, so i ask, is there any way to set/unset a object to ghost during game?

Physics options can’t be changed in the game engine. You can only suspend or resume object physics. In order to accomplish what you’re trying to do, you need to make multiple copies of the object, one with ghost and one without.

Not necessarily. With KX_GameObject.setParent() you can change to Ghost, when setting the third parameter to True.
While grabbing an item you normally parent it to a holder, so do this:

item.setParent(holder, 0, 1)

double post sorry :frowning:

hey thanks! ill try that now!

I think that using KX_GameObject.removeParent() will disable Ghost again, but I’m not sure. Or you could parent it again to an object with the third parameter set to False.

no, i was talking about what Mobious posted, we both posted at the same time
edit: i tested it with logic bricks, and seems that it works the first time, when you try to swich it back, it doesn`t works anymore

i think i will solve this later, some day im bored in development, for now ill leave as it is, anyway thanks for the help, it was really “helpful” lol

Here’s an example if you would be using a script. Press G to enable/disable Ghost on the Cube. Arrows to move the Player.

Attachments

Ghost00.blend (80 KB)

hey thanks!
this is awesome!
thanks again :smiley: