GameSalad

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Invalid JSON prompt

sinbotsinbot Posts: 77Member, PRO

I just spent forever working on this custom shape with Physics Editor and GS does not accept it. getting invalid json prompt. anyone have any idea what could be wrong?? I really need this to work because the sprites that GS creates are a bit too large to size down to make invisible walls. the image is 1920x1080.

Comments

  • adent42adent42 Posts: 1,336Key Master, Head Chef, Executive Chef, Member, PRO GameSalad Employee

    So I haven't actually looked into this, but a few thoughts:

    Creator may have a limit on the complexity of the collision shapes.

    Box2D only accepts convex shapes, so each shape that has a concave area is really multiple collision objects together. If you're doing the whole maze, that may just be too much.

    While it's annoying you may be better off breaking your maze into building blocks and adding the shapes to those.

  • AlchimiaStudiosAlchimiaStudios Posts: 1,015Member, PRO
    edited May 31

    @sinbot Can you post the JSON code here? I remember the export script for exporting from PES by default does not handle multi-polygonal collisions correctly, but it can be modified to do so. Here is an example below:

    -----------------Invalid JSON data as exported by PE-------------------

    {
    "rigidBodies": [
    {
    "normalized":false,
    "rescale":false,
    "origin":{"x":0,"y":0},
    "size":{"width":120,"height":104},
    "polygons": [
    [
    {"x": 1, "y": 50 },
    {"x": 28, "y": 0 },
    {"x": 92, "y": 0 },
    {"x": 120, "y": 49 },
    {"x": 91, "y": 51 }
    ],
    [
    {"x": 92, "y": 104 },
    {"x": 91, "y": 51 },
    {"x": 120, "y": 49 }
    ] (comma missing)
    [
    {"x": 45, "y": 102 },
    {"x": 5, "y": 102 },
    {"x": 5, "y": 62 }
    ] (comma missing)
    [
    {"x": 69, "y": 83 },
    {"x": 48, "y": 83 },
    {"x": 48, "y": 64 }
    ]
    ]
    }
    ]
    }

    ------------------Valid JSON ------------------------

    {
    "rigidBodies": [
    {
    "normalized":false,
    "rescale":false,
    "origin":{"x":0,"y":0},
    "size":{"width":120,"height":104},
    "polygons": [
    [
    {"x": 1, "y": 50 },
    {"x": 28, "y": 0 },
    {"x": 92, "y": 0 },
    {"x": 120, "y": 49 },
    {"x": 91, "y": 51 }
    ],
    [
    {"x": 92, "y": 104 },
    {"x": 91, "y": 51 },
    {"x": 120, "y": 49 }
    ],
    [
    {"x": 45, "y": 102 },
    {"x": 5, "y": 102 },
    {"x": 5, "y": 62 }
    ],
    [
    {"x": 69, "y": 83 },
    {"x": 48, "y": 83 },
    {"x": 48, "y": 64 }
    ]
    ]
    }
    ]
    }

    Back when this was first introduced GS staff swore the exporter addon was fine. But myself and others had many issues. See this thread for work-arounds and information:

    https://forums.gamesalad.com/discussion/90325/custom-collision-weirdness-with-physicseditor/p2

    Follow us: Twitter - Website

  • AlchimiaStudiosAlchimiaStudios Posts: 1,015Member, PRO
    edited May 31

    Here is the old script vs a modified script:

    Old:

    { "rigidBodies": [{% for body in bodies %} { "normalized":false, "rescale":false, "origin":{"x":{{body.anchorPointAbs.x}},"y":{{body.anchorPointAbs.y}}}, "size":{"width":{{body.size.width}},"height":{{body.size.height}}}, "polygons": [{% for fixture in body.fixtures %}{% for polygon in fixture.polygons %} [{% for point in polygon %} {"x": {{point.x}}, "y": {{point.y}} }{% if not forloop.last %},{% endif %}{% endfor %} ]{% if not forloop.last %},{% endif %}{% endfor %}{% endfor %} ] }{% if not forloop.last %},{% endif %}{% endfor %} ] }

    When it should be closer to this:

    { 
        "rigidBodies": [{% for body in bodies %}
        { 
            "normalized":false,
            "rescale":false,
            "origin":{"x":{{body.anchorPointAbs.x}},"y":{{body.anchorPointAbs.y}}},
            "size":{"width":{{body.size.width}},"height":{{body.size.height}}},
        "polygons": [{% for fixture in body.fixtures %}{% for polygon in fixture.polygons %}
                [{% for point in polygon %}
                    {"x": {{point.x}}, "y": {{point.y}} }{% if not forloop.last %},{% endif %}{% endfor %} 
                ],{% if not forloop.last %},{% endif %}{% endfor %}{% endfor %}
            ]
    
        }{% if not forloop.last %},{% endif %}{% endfor %}
        ]
    }
    

    However for it to be 100% correct you'd want to use this script but remove the last comma on the end block since no further collisions blocks occur. There is probably a better way to write this. Maybe someone can take a look.

    Follow us: Twitter - Website

  • sinbotsinbot Posts: 77Member, PRO
    edited June 1

    {
    "rigidBodies": [
    {
    "normalized":false,
    "rescale":false,
    "origin":{"x":0,"y":0},
    "size":{"width":1920,"height":1080},
    "polygons": [
    [
    {"x": 422, "y": 420 },
    {"x": 406, "y": 420 },
    {"x": 406, "y": 371 },
    {"x": 422, "y": 386 }
    ],
    [
    {"x": 625, "y": 771 },
    {"x": 642, "y": 771 },
    {"x": 642, "y": 825 },
    {"x": 625, "y": 824 }
    ],
    [
    {"x": 625, "y": 824 },
    {"x": 642, "y": 825 },
    {"x": 648, "y": 830 },
    {"x": 620, "y": 830 }
    ],
    [
    {"x": 422, "y": 386 },
    {"x": 406, "y": 371 },
    {"x": 426, "y": 382 }
    ],
    [
    {"x": 1703, "y": 563 },
    {"x": 1674, "y": 569 },
    {"x": 1649, "y": 569 },
    {"x": 1645, "y": 563 }
    ],
    [
    {"x": 893, "y": 763 },
    {"x": 905, "y": 763 },
    {"x": 905, "y": 1022 },
    {"x": 893, "y": 824 }
    ],
    [
    {"x": 902, "y": 164 },
    {"x": 852, "y": 164 },
    {"x": 851, "y": 155 },
    {"x": 902, "y": 155 }
    ],
    [
    {"x": 852, "y": 164 },
    {"x": 847, "y": 168 },
    {"x": 834, "y": 168 },
    {"x": 829, "y": 163 },
    {"x": 829, "y": 155 },
    {"x": 834, "y": 150 },
    {"x": 847, "y": 149 },
    {"x": 851, "y": 155 }
    ],
    [
    {"x": 406, "y": 371 },
    {"x": 506, "y": 371 },
    {"x": 524, "y": 382 },
    {"x": 426, "y": 382 }
    ],
    [
    {"x": 506, "y": 371 },
    {"x": 513, "y": 367 },
    {"x": 524, "y": 382 }
    ],
    [
    {"x": 191, "y": 454 },
    {"x": 253, "y": 454 },
    {"x": 267, "y": 462 },
    {"x": 191, "y": 462 }
    ],
    [
    {"x": 253, "y": 454 },
    {"x": 256, "y": 450 },
    {"x": 267, "y": 462 }
    ],
    [
    {"x": 513, "y": 367 },
    {"x": 513, "y": 282 },
    {"x": 524, "y": 261 },
    {"x": 524, "y": 382 }
    ],
    [
    {"x": 513, "y": 282 },
    {"x": 507, "y": 274 },
    {"x": 524, "y": 261 }
    ],
    [
    {"x": 1704, "y": 508 },
    {"x": 1704, "y": 514 },
    {"x": 1645, "y": 514 },
    {"x": 1649, "y": 508 }
    ],
    [
    {"x": 726, "y": 372 },
    {"x": 829, "y": 372 },
    {"x": 847, "y": 383 },
    {"x": 726, "y": 383 }
    ],
    [
    {"x": 829, "y": 372 },
    {"x": 834, "y": 366 },
    {"x": 847, "y": 383 }
    ],
    [
    {"x": 370, "y": 685 },
    {"x": 370, "y": 825 },
    {"x": 357, "y": 843 },
    {"x": 357, "y": 685 }
    ],
    [
    {"x": 370, "y": 825 },
    {"x": 374, "y": 830 },
    {"x": 357, "y": 843 }
    ],
    [
    {"x": 478, "y": 518 },
    {"x": 478, "y": 529 },
    {"x": 267, "y": 528 },
    {"x": 300, "y": 520 },
    {"x": 323, "y": 519 }
    ],
    [
    {"x": 507, "y": 274 },
    {"x": 326, "y": 274 },
    {"x": 305, "y": 261 },
    {"x": 524, "y": 261 }
    ],
    [
    {"x": 847, "y": 383 },
    {"x": 834, "y": 366 },
    {"x": 834, "y": 168 },
    {"x": 847, "y": 168 }
    ],
    [
    {"x": 326, "y": 274 },
    {"x": 318, "y": 279 },
    {"x": 305, "y": 261 }
    ],
    [
    {"x": 305, "y": 261 },
    {"x": 318, "y": 279 },
    {"x": 319, "y": 514 },
    {"x": 305, "y": 515 }
    ],
    [
    {"x": 319, "y": 514 },
    {"x": 323, "y": 519 },
    {"x": 300, "y": 520 },
    {"x": 305, "y": 515 }
    ],
    [
    {"x": 300, "y": 520 },
    {"x": 267, "y": 528 },
    {"x": 166, "y": 528 },
    {"x": 167, "y": 520 }
    ],
    [
    {"x": 374, "y": 830 },
    {"x": 888, "y": 830 },
    {"x": 888, "y": 843 },
    {"x": 357, "y": 843 }
    ],
    [
    {"x": 267, "y": 462 },
    {"x": 256, "y": 450 },
    {"x": 256, "y": 155 },
    {"x": 267, "y": 170 }
    ],
    [
    {"x": 267, "y": 170 },
    {"x": 256, "y": 155 },
    {"x": 273, "y": 164 }
    ],
    [
    {"x": 536, "y": 939 },
    {"x": 536, "y": 949 },
    {"x": 255, "y": 949 },
    {"x": 266, "y": 939 }
    ],
    [
    {"x": 266, "y": 939 },
    {"x": 255, "y": 949 },
    {"x": 262, "y": 935 }
    ],
    [
    {"x": 255, "y": 949 },
    {"x": 255, "y": 534 },
    {"x": 262, "y": 535 },
    {"x": 262, "y": 935 }
    ],
    [
    {"x": 262, "y": 535 },
    {"x": 255, "y": 534 },
    {"x": 249, "y": 528 },
    {"x": 267, "y": 528 }
    ],
    [
    {"x": 167, "y": 520 },
    {"x": 166, "y": 528 },
    {"x": 162, "y": 533 },
    {"x": 161, "y": 515 }
    ],
    [
    {"x": 256, "y": 155 },
    {"x": 829, "y": 155 },
    {"x": 829, "y": 163 },
    {"x": 273, "y": 164 }
    ],
    [
    {"x": 834, "y": 150 },
    {"x": 834, "y": 58 },
    {"x": 847, "y": 57 },
    {"x": 847, "y": 149 }
    ],
    [
    {"x": 834, "y": 58 },
    {"x": 828, "y": 52 },
    {"x": 841, "y": 47 },
    {"x": 852, "y": 52 },
    {"x": 847, "y": 57 }
    ],
    [
    {"x": 1645, "y": 514 },
    {"x": 1645, "y": 58 },
    {"x": 1649, "y": 47 },
    {"x": 1649, "y": 508 }
    ],
    [
    {"x": 1645, "y": 58 },
    {"x": 1641, "y": 52 },
    {"x": 1649, "y": 47 }
    ],
    [
    {"x": 1645, "y": 563 },
    {"x": 1649, "y": 569 },
    {"x": 1649, "y": 1032 },
    {"x": 1646, "y": 1022 }
    ],
    [
    {"x": 1646, "y": 1022 },
    {"x": 1649, "y": 1032 },
    {"x": 1640, "y": 1028 }
    ],
    [
    {"x": 1641, "y": 52 },
    {"x": 852, "y": 52 },
    {"x": 841, "y": 47 },
    {"x": 1649, "y": 47 }
    ],
    [
    {"x": 828, "y": 52 },
    {"x": 169, "y": 52 },
    {"x": 156, "y": 48 },
    {"x": 841, "y": 47 }
    ],
    [
    {"x": 169, "y": 52 },
    {"x": 161, "y": 57 },
    {"x": 156, "y": 48 }
    ],
    [
    {"x": 161, "y": 57 },
    {"x": 156, "y": 1033 },
    {"x": 156, "y": 48 }
    ],
    [
    {"x": 888, "y": 843 },
    {"x": 888, "y": 830 },
    {"x": 893, "y": 824 },
    {"x": 894, "y": 848 }
    ],
    [
    {"x": 1640, "y": 1028 },
    {"x": 1649, "y": 1032 },
    {"x": 156, "y": 1033 }
    ],
    [
    {"x": 894, "y": 848 },
    {"x": 905, "y": 1022 },
    {"x": 894, "y": 1022 }
    ],
    [
    {"x": 905, "y": 1022 },
    {"x": 911, "y": 1028 },
    {"x": 889, "y": 1027 },
    {"x": 894, "y": 1022 }
    ],
    [
    {"x": 889, "y": 1027 },
    {"x": 911, "y": 1028 },
    {"x": 156, "y": 1033 },
    {"x": 165, "y": 1027 }
    ],
    [
    {"x": 165, "y": 1027 },
    {"x": 156, "y": 1033 },
    {"x": 162, "y": 1024 }
    ],
    [
    {"x": 162, "y": 1024 },
    {"x": 156, "y": 1033 },
    {"x": 161, "y": 515 },
    {"x": 162, "y": 533 }
    ]
    ]
    }
    ]
    }

    this is the code for the collisions json. far as I can tell it looks correct but then again I am in over my head with this lol

  • AlchimiaStudiosAlchimiaStudios Posts: 1,015Member, PRO

    @sinbot said:

    this is the code for the collisions json. far as I can tell it looks correct but then again I am in over my head with this lol

    That does look correct. I guess it's just too complex as Adent said.

    Follow us: Twitter - Website

  • sinbotsinbot Posts: 77Member, PRO

    so just for the record in case someone happens upon this thread with same issue.. it does in fact have to be one solid shape. It can be angular of course but all the vertex must be connected.

Sign In or Register to comment.