R0J0hound's Forum Posts

  • Here's one idea how to do it. I went with doing rotation similar to how the construct 3 editor lets you rotate objects.

    dropbox.com/s/zjsrx3a43imr2a0/drag_and_rotate.capx

  • Here's a simplified single object, one instance variable version.

    dropbox.com/s/6qs81zmktsd3so8/yaxis_rotate.c3p

  • Also it’s possible replicate a cube with mesh distort. Then with a bit of math you can rotate it any way you like.

    construct.net/en/forum/construct-3/your-construct-creations-9/example-mesh-distort-sphere-161470

  • Well there is a depth buffer, and transparency does mostly work in 3D. Not always though.

    You can rotate the corners with a bit of math. It’s just a matter of applying them to a distort mesh.

    One idea place four sprites at

    -32,-48

    32,-48

    32,48

    -32,48

    These will serve as our points. Give them three instance variables z, Newx and newz.

    then you can rotate them with:

    var a=0
    var sa=0
    var ca=0
    
    every tick:
    — set a to time*10
    — set sa to sin(a)
    — set ca to cos(a)
    -- sprite: set newx to self.x*ca-self.z*sa
    -- sprite: set newz to self.x*sa-self.z*ca
    
    every tick
    — card: set size to (1,1)
    -- card: set distort mesh to 2,2
    -- set distort at 0,0 to card.x+sprite(0).newx, card.+sprite(0).y, 32+sprite(0).newz, -1,-1
    -- do the same for the other points: 
    0,1 with sprite(1)
    1,1 with sprite(2)
    1,0 with sprite(3)

    sorry i trailed off with the bit where you set the distort points. generally youd have card have a size of 1,1 and place the points with absolute. Unless something changed you can’t use a negative z for a distort point, so you’d need to shift things a bit higher.

  • Cool. Glad that helped.

  • One idea for the jumping would be to relax the spring forces momentarily then make the spring forces stiffer for a bit. But I guess there may be other ideas.

    Making other shapes should be possible, but it just would take more setup. All the rest lengths of the edges, and all the rest areas of the triangles. The other issue is while a grid is easy to texture with distort meshes, other shapes could be trickier.

  • It’s hard to reason about more complicated cases. One thought that comes to mind is objects that are side by side on the x axis may be considered overlapping with that bounding box code. That would throw things off. Maybe shrinking it a bit may help:

    A.bbboxleft is between B.bboxLeft-A.width+1 and B.bbboxRight-1

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I changed mine so z up is positive and compared what I did with yours:

    yours: dy = (A.y+A.z)-(B.y+B.z)-(A.sy-B.sy)/2
    mine: dy = (A.y+A.z)-(B.y+B.z)-(A.sy-B.sy)/2
    
    yours: dz = -A.z+B.z-(A.sz-B.sz)/2
    mine: dz = A.z-B.z-(A.sz-B.sz)/2
    
    yours: best = ((abs(dy)-(A.sy+B.sy)/2)>((abs(dz)-(A.sz+B.sz)/2))?dy:dz
    mine: best = ((abs(dy)-(A.sy+B.sy)/2)>(abs(dz)-(A.sz+ B.sz)/2))?dy:dz

    It's just your dz equation that is off. The rest looks correct from what I can tell.

    You can do your own bounding box check if you want to reserve the collision poly for collisions. These two conditions would do that:

    A.bbboxleft is between B.bboxLeft-A.width and B.bbboxRight
    A.bbboxTop is between B.bboxTop-A.Height and B.bbboxBottom
  • AnD4D

    Here is one possible way if all your layers are visible.

    global text name="fish"
    
    is layer name visible
    -- layer exists
    else
    -- layer doesn't exist
  • Here is the sorting with the perspective you're using.

    dropbox.com/s/m1p2f090xmqa230/alt_iso_sort.capx

  • I like how simple alextro's formula is. Unfortunately that will only work with isometric blocks with the same size.

    For different sized blocks you need to figure out which objects are in front of the other. Consider the simplest case of two blocks. This site does a nice job at explaining a way to do that:

    bannalia.blogspot.com/2008/02/filmation-math.html

    Once you have a way to decide which of any two blocks should be in front of the other you can use that to progressively sort the scene. You only need to sort objects visually overlapping each other. For making everything sort more instantly, you can use a topo sort if needed.

    In my latest tests I've found the step of figuring out which of two blocks should be in front of the other is closely related to pushing one object out of the other for Collison detection. Basically find the normal of the collision/overlap of each pair. Even if the objects aren't overlapping in 3d it's possible to find this normal. If you're not familiar with normals, they are just the 3d direction from one contact face to the other object.

    Anyways with that you dot product the normal vector with the direction of the screen. If <0 then one object is in front, otherwise the the other is in front.

    Here's a test of that.

    dropbox.com/s/9veb43lyxd7bja0/iso_sort3simplified.capx

    Anyways, for the perspective you're using it will be simpler than sorting for a isometric view, but the idea is similar. I was attempting to adapt my example to your perspective but not much luck yet. Hopefully it gives some ideas, or you stumble on a simpler solution.

  • Link now fixed. Guess I need to verify the links I’m copying from Dropbox. That’s been happening a lot lately.

  • alextro

    Ah, thanks man. That's at least the second time i've done that this week. Link fixed now.

  • Here's a test using verlet physics since I've been using that a lot lately. Looks more like a pony tail, but if using a distort mesh stretched over the points it may look better.

    dropbox.com/s/niureg675c6ae8h/scarf_verlet.capx

    Further test adding wind and air resistance. Events got a bit messy. Not super happy with the wind.

    dropbox.com/s/37fi58li47jpspc/scarf_verlet_wind.capx

    There are probably other creative ways to make more appealing scarfs.

  • Here is a test of keyboard controls. It involves two steps:

    1. find the minimum and maximum y of all the points.

    2. apply an acceleration to the points while a key is down. It uses the previous ymin,ymax to apply more acceleration to the top points than the bottom points. This causes the object to roll.

    The formula used is: 800*mdt*((self.Y-ymax)/(ymin-ymax))^10

    (self.Y-ymax)/(ymin-ymax) gives a value from 0 to 1 for each point. The top points will have a value of 1 and the bottom have a value of 0. It's changes linerarly for the points in between. I added the ^10 to give it a steeper curve. Basically with that the points at the top will still have a value of 1 but more of the points below will have a value closer to 0.

    The 800 is the force, and mdt is the timestep.

    Can be read as a force of 800 is applied to the top of the blob. The force bleeds to some of the points close to the top but most of the low points will barely have any force.

    I only did it for the plain c2 version but it should be simple enough to add the the others. Events 7-12.

    dropbox.com/s/s1m388u87wbajn0/jello_no3rdParty_keyboard.capx