U
U
Urukhayy2015-03-04 16:13:22
Programming
Urukhayy, 2015-03-04 16:13:22

Which is better of the two options?

Let's say we have 2 virtual worlds. And an entity (a physical virtual object), which stands in one of the virtual worlds. The user can interact with this object, while he must be in the same virtual world with the object. Moreover, this object can be created both for one virtual world and for several. In addition, we can find out in which virtual world the user is currently.
Attention question. If you need to use a second virtual world, and exactly the same object, with the same coordinates, and for almost the same purposes, do you need to create a second object in another virtual world? After all, an object can be in several virtual worlds at once.
So there are 2 possible answers:
1) You can create 1 object for all virtual worlds, and when interacting with it, check (if, switch) the virtual world, and perform actions corresponding to the virtual world.
2) Create the same object for each virtual world.
Yes, the question is very abstract. But in two variants, the optimization is affected by the following:
In the first version, only the check affects the optimization.
In the second, the load is carried by an additional object, which can load information about the object, and other aspects, such as scanning the user's draw area in order to detect objects.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Evgenievich, 2015-03-04
@banderos120

It seems to me that each virtual world should have its own separate object. Let them all be identical in their properties, however, it seems to me that if you interact with one object in different ways, you can get a conflict. I have an analogy with global variables in my head.

D
Dvvarreyn, 2015-04-24
@Dvvarreyn

Something inspired.

- Feynman! I know why all electrons have the same charge and the same mass.
- Why not?
Because it's all the same electron.
In my opinion, the division into objects and how many of them should be determined not by abstract considerations, but by specific needs - the number of these very additional aspects and other things, what “almost for the same purposes” means, etc.
There is also a third option.
It is possible to have one object that stores common universal properties. And instances, which already have their own in each world. The singleton template is cleverly called, it seems.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question