Unity Java Unreal Engine WebGL Any situation for for delete-able objects that are not deleted?

Any experiences with making custom Game Engines?

  • Meh, no but its fun to look into

    Votes: 0 0.0%

  • Total voters
    6

Saki_Sliz

Well-Known Member
May 3, 2018
1,403
995
Can you think of any situation where a game object needs to be "deactivated" but be ready to be "reactivated" for some reason?

Let me add an image to this post so it is slightly interesting.

343519
(testing character and some basic tiles, in the future I want to cover the ground with grass, and play with effects that make the dirt look uneven, such as with wagon tracks, as well as better transition between trail and grass patches.)

While this question is targeted towards experienced programmers, because I am talking about situations where an object (in terms of object-oriented programming) which represents a game object needs to be deleted or deactivated, but not completely: specifically, when do we need to reactivate a very specific object, with all of its data, or at least still keep it running if it is hidden. Anyone can answer this question.

This would work mostly with temporary data.
Any data that is permanent in the game world, such as, the location of grass, what characters where, etc, tend to be better handled by a higher complex system, like the map god object, character god object, whose job it is to answer question about, "I'm loading in character X, what is character X's state? values of variables such as clothes?"

I need any possible suggestions, so I will try to keep the question simple, the issue though is that it is hard to describe the concept in as few words as possible, because there are lots of ways things can be worked around if you are not familiar with making game engines. Just know that simpler cases are better. If the case is too complex, such as NPC's who move around in parts of the game not seen (inside a house), more often then not the object is just a puppet being controlled by a god object, or some other workaround.

For example: in Unity, I made a little notification object, which when activated would be a notification for the programer during the game's development. The object would already be in the scene, only deactivated. What I would do is when a notification came in, I would reactivate the object, which would make it do its thing, such as playing its Enter_Animation. Once it was done (no more notifications), it would play its Exit_Animation. It would then set some variables and then deactivate itself. The key thing here is that, when the object was reactivated, since it was not deleted only reactivated, all the variables and data were the same, I used a one-shot trigger trick where, if the variables from deactivation carried over (like setting last_state = deactivated; ) now that it was active again, it could check its variables and realized it was reactivated, so it would run through the startup code. I did this so I didn't have to deal with unity's clunky object creation/removal, and so that I wouldn't have to reconnect the controller to the notification entity, and some other stuff to save a few clock cycles.

So this is one case where I deactivated and reactivated the exact same object, only because it was easier than deleting and make a new one each time.

I would like to know of any suggestions where it would help if one object came back after being deleted.

This question may seem both vague and specific.





More technical information.

Currently, I am working on my own game system/engine in C#. I am currently tackling the challenge of object/memory management and I hit an interesting question. Right now I am trying to make it so that objects can be
~ created: fully, for the first time, as in loading in data. it is possible for similar objects to share resources so there is no duplication in memory, ie, grass objects do not each have a unique sprite that they load in, but rather they share a pointer to the same asset content.
~ removed: completely, like when unloading.
~ as well as deactivated: a type of temporary removal that does not unload, we just don't run code for this object, but we haven't deleted it yet, basically pretend it's no longer in the game.
~ and activated: basically create an object, but since there is another object that is deactivated of the same type, we will just repurpose that old object to be our new object, instead of actually allocating new memory.

active objects operate as normal, like characters in a scene, grass on the ground.
Basically, deactivating an object is like deleting an object.

I want to figure out if there are situations where we want to deactivate an object, but not lose its data. In fact, would there be situations where we need to reactivate this very specific object again? and not just repurpose it as some other version of it. I want to know because if I can be aware of said situations, then by understanding the situations, I can understand what mechanism is being worked on, and if I can predict that this mechanism may be used, I can code it in now before I get too deep into this part of the code.

in unity, when you reactivate an object, you are reactivating that specific object. Currently, with my game system (idea, still coding it), the way it saves memory (many other games do a very similar trick, using different techniques) is that objects that get deleted, are actually just deactivated, only to be reused as a new similar object, this way the object does not need to be recreated. I am using this technique to save time and make sure I am managing memory well.

as it stands, technically, if I wanted to do the same thing I did with the notification system, it would work. That is because there is only one notification object at any one time, so that means when it gets removed (deleted, but actually it is just deactivated) and a new one is made, it just ends up reactivating the same instantiation that existed before. This is but a trick, and would only work if you understood at a deep level how my game engine worked. It would be best if users could actively state that they want to preserve a specific object(unity singleton would be like this, but that is a high-level object, the gameObject manager is more mid-level oriented). However, if there are multiple objects of the same kind, and I want to reactivate a very specific object, if it were to make a new object like normal, it would reuse the most convenient deactivated object, overwriting its previous settings. So the trick wouldn't work, I would have to use a command to preserve an object to make sure it is not lost in a sea of deactivated objects.

If there is a situation where I do want to recall a very specific object, so that it can continue working as normal without needing to be managed by a god object, then I need to modify my code to allow for this. an object that is deactivated with the intent of preserving it needs to be kept separate from the objects that were deactivated because they were deleted.


Has anyone else tied making custom game engines before? I think this is my third time? Previously I have focused on the graphics pipeline (but basic, just making custom webgl game engine), and some basic architecture, this time I am focusing on how objects are managed to make a fully working game, and not just a tech demo.