Picking up a gun on the ground to make my player use.

So, when picking up a gun. The gun that is currently sitting on the floor is active. When a player stands on top of the gun and presses “p” or whatever. He picks up the gun… my question then is. How is that done? I’m getting the idea that what’ll happen is, the player already technically has all the guns instantiated as children. BUT, only the starter guns Active setting is true. All other guns are deactivated. Now, when the player “picks up” a gun, the gun on the floor is deactivated, or deleted! And the gun he picks up is activated in the child class, and the other gun he traded the gun on the floor for is deactivated. Is that the correct current way to go with that? Are there any problems with that approach? I’m sure using inventories might be a bit different, but I haven’t delve into that.

1 Like

That’s a pretty accurate idea on what happens. The details are in how all of that is wired up, but you’ve described a reasonable approach to the problem.

1 Like

I think that’s a perfectly fine approach. Others might have a better opinion on this. If I’m not mistaken, doing it this way will ensure that all your weapons (as complex or simple as they may be) are loaded when the level is loaded (I think? Not sure if that’s how it works with deactivated objects on loading). At the very least, if you were to do things like switching back/forth between weapons, your objects wouldn’t have to be reloaded into memory. This activate/deactivation is the concept behind pooling, of course, which is meant to increase performance. So I would think this is the smart way to do it!

1 Like

Really appreciate the quick responses! Thank you very much! I’ll get started on the idea now