Will collision ever be a built in feature?

3absh3absh Member Posts: 601

Something as basic as collision ought to be built in within the engine instead of using an external plug-in don't you think?


The physics body editor is not working on my Mac for some reason and I have to look for a Windows computer every time I need to change the collision shape of an actor.


A bit inconvenient

Comments

  • bob loblawbob loblaw Member, PRO Posts: 793

    physics body editor works perfect on my macbook (high sierra), but bricks on my imac (catalina).

  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772

    Physics Body Editor works fine for me on my imac running 10.14.5.

    Though it would be nice to have that functionality built right into the editor.

    FYI, in the online version of Gamesalad you can auto trace an image to build a collision shape. You can't edit the shape once it's auto traced but if it's a pretty simple shape it does a good job of it.

  • ForumNinjaForumNinja Key Master, Head Chef, Member, PRO Posts: 554

    What @jamie_c said. The online version of GS has an auto-trace feature to generate the collision shape for you, but it's not currently editable after the fact.

    I just double checked and it looks like after you auto-trace the collision shape in the online version, you can publish your game to your portfolio, download it, and edit it with the Mac version of GS with the auto-traced collision shape remaining intact.

  • bob loblawbob loblaw Member, PRO Posts: 793

    you don't need physics body editor to make custom collisions. depending on how complex the number of polygons in your custom shape are, and how much time you want to take, you can write your own .json files with a simple text editor, and import them into your project.

  • bob loblawbob loblaw Member, PRO Posts: 793

    i’ll see if i can slap something together. if you look up gamesalad custom collision shapes, there’s a couple of pages that describe it in a really basic sense.

  • bob loblawbob loblaw Member, PRO Posts: 793

    in a nutshell, when you have something that isn't rectangle shaped you need to break it up into a group of polygons.

    this is just a simple explanation I hope makes sense.

    if you look at the attached .png file (arrow image), it can be broken up into four triangles (top, both 'legs' and centre). when you create a .json file for the polygons, you basically note the coordinates of the vertices/corners relative to the image. so in the attached image I've set it up to be 100x100px to make the numbers easier.

    two ways to do it.

    if you make a file like the ones physics body editor creates, you assume the image is 1x1units (ie. left x position is 0, middle is 0.5, right is 1, bottom y position is 0, middle is 0.5, top is 1, etc). when you use this method no vertex x or y position will be greater than 1, as below. the bold text under "polygons" denotes the unit vertices for each individual polygon, while the bold text under "vertices" just lists all the vertices within the image. the rest of the text forms the body of the json file (and use your own name and image path):

    {

    "rigidBodies":

    [{"name":"collisionExperiment","imagePath":"collisionExperiment.png","origin":{"x":0,"y":0},

    "polygons":

    [

    [{"x":0.2,"y":0},{"x":0.5,"y":0.2},{"x":0.3,"y":0.6}],


    [{"x":0.5,"y":0.2},{"x":0.7,"y":0.6},{"x":0.8,"y":0}],


    [{"x":0.5,"y":0.2},{"x":0.7,"y":0.6},{"x":0.3,"y":0.7}],


    [{"x":0.2,"y":0.6},{"x":0.8,"y":0.6},{"x":0.5,"y":0.8}]

    ],

    "circles":[],

    "shapes":[{"type":"POLYGON",

    "vertices":

    [{"x":0.2,"y":0.0},

    {"x":0.5,"y":0.2},

    {"x":0.8,"y":0},

    {"x":0.7,"y":0.6},

    {"x":0.8,"y":0.6},

    {"x":0.5,"y":0.8},

    {"x":0.2,"y":0.6},

    {"x":0.3,"y":0.6}]

    }]

    }],

    "dynamicObjects":[]

    }


    option 2 is a lot cleaner and easier to put together (I probably should have led with it).

    same principle, but you use the pixel coordinates of the image. the attached image file is 100x100px. put in the width and height of the image file in the "size" portion, then just list the coordinates (as pixel positions within the image) for each vertex of each polygon (under "polygons"), as noted below (if you plot on a grid and connect the dots you'll get the arrow image). if you paste the below text into a .json file and edit in a text editor, you only update the bold parts to suit your image's collision.

    {

      "rigidBodies": 

      [

        {

        "normalized":false,

        "size":{"width":100, "height":100},

        "polygons":

          [

            [{"x":20,"y":0},{"x":50,"y":20},{"x":30,"y":60}],


            [{"x":50,"y":20},{"x":70,"y":60},{"x":80,"y":0}],


            [{"x":50,"y":20},{"x":70,"y":60},{"x":30,"y":70}],


            [{"x":20,"y":60},{"x":80,"y":60},{"x":50,"y":80}]

          ]

        }

      ]

    }


    both methods require you to work out the vertices of your polygons on your images, and obviously the more awkward shapes in an image, the more polygons you will probably need to make. the attached gs demo has the arrow with the manually created collision applied to it.


  • ArmellineArmelline Member, PRO Posts: 5,364

    PhysicsEditor still works great on Macs, maybe just eat the cost for the sake of convenience? It's much better anyway, imo.

  • bob loblawbob loblaw Member, PRO Posts: 793

    for sure those things are definitely more convenient, but nothing wrong with also knowing how to do manually.

  • UltraLionBluUltraLionBlu Member Posts: 157

    Thanks, the second method seems much better, but I join those who would prefer the editable shapes directly in gamesalad: D

Sign In or Register to comment.