Hitbox Question

Caleb Burns GamesCaleb Burns Games Member, BASIC Posts: 6

Hi there,

I have a question that remained unanswered from my previous post, so I figured asking the second part would help

Is it possible to use JSON to create a 100x100 hitbox for the below image? The image is 128x128, and I put a purple square to show where I want it to be. I tried making one using Physics Body Editor but it hasn't worked; Gamesalad just spits it out when I try to enter it in the custom hitbox section. The black sections are transparent in-game.


Comments

  • freneticzfreneticz SwedenMember, PRO Posts: 777

    I use physics body editor also, try to make it not so much like a box....just change little so it draws some green lines in the editor

  • Caleb Burns GamesCaleb Burns Games Member, BASIC Posts: 6

    @freneticz Thanks man. I got the green lines like you said, but Gamesalad still spits it out, I think it's all of the fluff in the JSON code. Do your files usually look like this when they work?

    {

       "rigidBodies": [

           {

               "name": "Box",

               "imagePath": "../Users/Caleb Burns/Pictures/Video Game Assets/RobotWithDesiredHitbox.png",

               "origin": {

                   "x": 0,

                   "y": 0

               },

               "polygons": [

                   [

                       {

                           "x": 64,

                           "y": 2

                       },

                       {

                           "x": 64,

                           "y": 0

                       },

                       {

                           "x": 114,

                           "y": 0

                       },

                       {

                           "x": 114,

                           "y": 100

                       }

                   ],

                   [

                       {

                           "x": 114,

                           "y": 100

                       },

                       {

                           "x": 14,

                           "y": 100

                       },

                       {

                           "x": 62,

                           "y": 2

                       },

                       {

                           "x": 64,

                           "y": 2

                       }

                   ],

                   [

                       {

                           "x": 14,

                           "y": 100

                       },

                       {

                           "x": 14,

                           "y": 0

                       },

                       {

                           "x": 62,

                           "y": 0

                       },

                       {

                           "x": 62,

                           "y": 2

                       }

                   ]

               ],

               "circles": [],

               "shapes": [

                   {

                       "type": "POLYGON",

                       "vertices": [

                           {

                               "x": 14,

                               "y": 0

                           },

                           {

                               "x": 14,

                               "y": 100

                           },

                           {

                               "x": 114,

                               "y": 100

                           },

                           {

                               "x": 114,

                               "y": 0

                           },

                           {

                               "x": 64,

                               "y": 0

                           },

                           {

                               "x": 64,

                               "y": 2

                           },

                           {

                               "x": 62,

                               "y": 2

                           },

                           {

                               "x": 62,

                               "y": 0

                           }

                       ]

                   }

               ]

           }

       ],

       "dynamicObjects": []

    }

  • ArmellineArmelline Member, PRO Posts: 5,397
    edited March 30

    I use PhysicsEditor as I found it easier and more reliable than PhysicsBodyEditor, but it's not free.

    Here's what it produced for that image. I matched the purple box.

    { 
       "rigidBodies": [
       { 
           "normalized":false,
           "rescale":false,
           "origin":{"x":0,"y":0},
           "size":{"width":128,"height":128},
           "polygons": [ 
               [
                   {"x": 14, "y": 100 },
                   {"x": 14, "y": 0 },
                   {"x": 114, "y": 0 },
                   {"x": 114, "y": 100 } 
               ]
           ]
       }
       ]
    }
    


  • Caleb Burns GamesCaleb Burns Games Member, BASIC Posts: 6

    @Armelline You're a life saver, thank you so much for the hitbox code. I'll be sure to put you in the credits of my game

  • ArmellineArmelline Member, PRO Posts: 5,397

    Happy to help! Let me know if you need any others done.

    This is the software I used, but it's fairly expensive for what it is: https://www.codeandweb.com/physicseditor

Sign In or Register to comment.