Semi-3D Mechanic!

Discuss game development design and post your game ideas

Post » Thu Apr 16, 2015 8:59 pm

So, here's my idea for a semi-three dimensional world:

Every object has an invisible "locator" object. This is the object that does the actual moving around and stuff. There are also two more objects: the shadow and the display object. The locator object has an instance variable called "Z," which is added to its Y position to determine the location of the display object. The shadow object simply looks for the first object below the display object (on the Z axis, mind you - not the Y axis) and displays there. Simple, right? Wrong.

For this to all render correctly, we have to sort the objects by Y and Z positions. If two objects have different Y values, the one with a higher Y displays in front of the other. This is fairly simple - assign each object a "ZOrder" instance variable and have the system go through each object by Z Order (ascending), sending each instance to the top of the layer as it does. Simple. But for the Z position, things get complicated. If two objects have different Z values, the same thing happens, except it overrides the previous value given if needed. But then, just using this system, we come across problems. If there are many, many objects, we see that some render incorrectly for a frame or two before being corrected by the system. This will not do. Plus, the sorting gets a little complicated when everything is the same object, but every instance has a variable or two determining its behavior and appearance. It's not the instance variables that are the problem, it's the fact that everything is an instance of the same object. Things get weird when we do this, so then everything has to have an "ID" variable, assigned either at the start of the layout or in the editor - possibly both - that we use to select it, which is much too complicated and will suck up memory faster than an industrial vacuum when using lots of objects.

So, you read that wall of text. Now, I have something to ask:

Could anyone help with the optimization of this? It will work, but it will be VERY (and I mean very) laggy if it does, so I need some way of optimizing it or just taking shortcuts while sorting. But ANYTHING will help.
B
11
S
3
G
4
Posts: 38
Reputation: 3,447

Post » Thu Apr 16, 2015 9:31 pm

A search for "isometric sorting" or "filimation engine" can give approaches similar to what you want. Based on what you know any two objects can be sorted based on their x,y and z. One thing to think of is they only need to be sorted if they overlap visually. To sort the objects it basically means a "topological sort" of the objects. A way to reference two separate instances of the same object is to use a family, then you can pick one instance like normal and the other with the family.

I've done it before with isometric. The only difference to your idea is how you'd compare the two instances to see which is in front.
viewtopic.php?f=147&t=79043&p=648340&hilit=isometric#p648340

I found it can be made faster if you use an actual topological sort algorithm
https://dl.dropboxusercontent.com/u/542 ... test2.capx
B
92
S
32
G
107
Posts: 5,274
Reputation: 69,959

Post » Sun Apr 26, 2015 9:25 am

Thanks @R0J0hound
B
157
S
27
G
17
Posts: 910
Reputation: 32,588

Post » Wed Aug 19, 2015 11:51 pm

@R0J0hound cool I'll try it. Thanks.
B
11
S
3
G
4
Posts: 38
Reputation: 3,447


Return to Game Development, Design & Ideas

Who is online

Users browsing this forum: No registered users and 1 guest