local physicsData = require ("physicsdata").physicsData(1.0) physics.addBody( shooter, "static", physicsData:get("alien1"))
This works fine, but when using the SSK2 collision calculator
local physicsData = require ("physicsdata").physicsData(1.0) physics.addBody( shooter, "static", physicsData:get("alien1"), {filter = myCC:getCollisionFilter( "shooter" ) } )
This resets the physics body to a rectangle.
Anyone knows how to fix this?
Interesting: I didn’t make the calculator to be used with other tools, but it probably can be.
Can you make a mini project that can be downloaded and run which demonstrates this?
I want to help you, but I don’t want to make an example of my own demonstrating this. I’d rather see what you are doing.
You should be able to do this with just a few files:
- physicsdata.lua
- One or more images.
- main.lua
- config.lua
- any file(s) needed to load physics edited file in physics editor (I have a copy and want to see the body shape in the editor)
Just make sure it is super small and I’ll download it and give it a try.
Thanks.
I should have seen this from your post. You’re passing in two sets of params to the add body call:
physics.addBody( spike, "static", physicsData:get("spike"), {filter = myCC:getCollisionFilter( "spike" ) } ) ^ 1 ^ 2
You can’t do that.
Additionally, the first set of params from physicsData is a multi-body set which has defined its own set of categoryBits and maskBits for the body.
However, I have hacked together a solution for the example you gave me that may be more widely applicable if you want to use the calculator still.
Snippet of important code:
-- 1 Get body params from physicsData local body\_params = physicsData:get("spike") -- 2 print body\_params before table.print\_r(body\_params) -- 3 Replace body\_params filter categoryBits and maskBits with calculator values body\_params.filter.categoryBits = myCC:getCategoryBits( "spike" ) body\_params.filter.maskBits = myCC:getMaskBits( "spike" ) -- 4 print body\_params before table.print\_r(body\_params) -- 5 Use the modified body physics.addBody( spike, "static", body\_params )
Modified project:https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2020/03/example.zip
One thing I couldn’t figure out was, what was going on with your physics editor body. Its seems like it should be a multi-body shape, but when I dumped it, there was just one body definition.
If you do end up using multi-body definitions, you’ll need to expand the code I gave to you to sub-bodies for cases where a shape has one.
Interesting: I didn’t make the calculator to be used with other tools, but it probably can be.
Can you make a mini project that can be downloaded and run which demonstrates this?
I want to help you, but I don’t want to make an example of my own demonstrating this. I’d rather see what you are doing.
You should be able to do this with just a few files:
- physicsdata.lua
- One or more images.
- main.lua
- config.lua
- any file(s) needed to load physics edited file in physics editor (I have a copy and want to see the body shape in the editor)
Just make sure it is super small and I’ll download it and give it a try.
Thanks.
I should have seen this from your post. You’re passing in two sets of params to the add body call:
physics.addBody( spike, "static", physicsData:get("spike"), {filter = myCC:getCollisionFilter( "spike" ) } ) ^ 1 ^ 2
You can’t do that.
Additionally, the first set of params from physicsData is a multi-body set which has defined its own set of categoryBits and maskBits for the body.
However, I have hacked together a solution for the example you gave me that may be more widely applicable if you want to use the calculator still.
Snippet of important code:
-- 1 Get body params from physicsData local body\_params = physicsData:get("spike") -- 2 print body\_params before table.print\_r(body\_params) -- 3 Replace body\_params filter categoryBits and maskBits with calculator values body\_params.filter.categoryBits = myCC:getCategoryBits( "spike" ) body\_params.filter.maskBits = myCC:getMaskBits( "spike" ) -- 4 print body\_params before table.print\_r(body\_params) -- 5 Use the modified body physics.addBody( spike, "static", body\_params )
Modified project:https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2020/03/example.zip
One thing I couldn’t figure out was, what was going on with your physics editor body. Its seems like it should be a multi-body shape, but when I dumped it, there was just one body definition.
If you do end up using multi-body definitions, you’ll need to expand the code I gave to you to sub-bodies for cases where a shape has one.