Semi-3D Mechanic!

0 favourites
  • 4 posts
From the Asset Store
3D Car Pack 1
$2.99 USD
3D models + Rendered Low-Poly Cars in isometric, top-down, and side angles.
  • 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.

  • 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

  • Thanks R0J0hound

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • R0J0hound cool I'll try it. Thanks.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)