What should I do with holstered weapons, items and other class instances with no world location?


I’m working on my inventory system, and I’ve been trying to work out what is the conventional way to handle things like weapons once they are holstered?

I don’t want to destroy them because I want to keep the custom materials and scope that the player may have applied to them, strictly using the purple class “prototype” (if I may use a JavaScript term) has other issues too. So I do want to work via blue reference to a class.

If they dont have collision in and of themselves, just hide the Actor ingame till your need it again.

Either that or you could designate a safe location outside the map (or even under it) where you transport all your unused weapons when they are holstered.

Think outside the box, there are plenty of options.

yeah I thought about that.

It just seems dirty.

I want to put things away in nice little boxes that feel obey convention.

“Convention” can be a very strange and abstract thing in game development :stuck_out_tongue:

Quick and dirty can sometimes be the most lite weight and effective means of achieving something.

Ive used the method above before with a pooled AI system, instead of destroying the AI when they died, i just moved their location somewhere out of sight until i needed another one again and i just reset its properties when it “respawned”. It reduced the performance overhead of having to spawn an new AI Actor in the world considerably since there were alot of AI units and they would usually die fairly quickly and need to respawn again soon as well.

Why don’t you just make the object invisible and disable its collision?

Cycle through the attached components and disable their collision, same for the mesh.

Fair call guys, I had thought about this, I was worried that “somewhere” it would be updating the location of this object and sending it’s new location via network traffic.

In this case I see no reason for it to ever exist any where once it is picked up by a player, it’ll just be something the player contacts to receive it’s related variables, like ammo and appropriate skeletal mesh. I’ll just make sure it is destroyed when it is no longer needed, like when the player dies.

Ahh this is starting to get quite heavy, I mean I also need the playercharacter to disappear when they use a vehicle, maybe I need some sort of “sleep” function