Futile icon indicating copy to clipboard operation
Futile copied to clipboard

Integrate physics with Futile

Open MattRix opened this issue 12 years ago • 9 comments

Integrate with the built-in Unity physics engine. Create a separate physics library/engine/thing to do this so that it doesn't overcomplicate the normal Futile stuff. It'll probably be stored as a separate github project.

MattRix avatar Nov 01 '12 16:11 MattRix

I have tried to add game objects in back of the FSprites for the collisions, but the edges of the object and sprite dont seem to match up. I have taken the width/height of the FSprites on a 1x scale and scaled the objects accordingly. It might be a mistake on my end though, I am still getting used to C# and unity. You can see my example project trying to wrap the Physx engine and Futile over at https://github.com/tmuntan1/futile-physics.

tmuntaner avatar Nov 13 '12 14:11 tmuntaner

@tmuntan1 Hmm, yeah I think the issue with yours is that the banana is a trimmed sprite, so using sprite.width and sprite.height (which return the untrimmed size) won't be accurate if you're expecting it to be the same size as the quad. Instead you could use sprite.localRect.width and sprite.localRect.height, although in a lot of cases the untrimmed size will be what you actually want.

MattRix avatar Nov 14 '12 16:11 MattRix

Ok, thank you and I will check it out.

tmuntaner avatar Nov 14 '12 16:11 tmuntaner

@tmuntan1 oh and note that if you do want to use sprite.localRect, you'll have to offset by the localRect.x and y as well because the trimmed quad is positioned based on the untrimmed image size, so the x and y will be slightly off if you keep them at 0,0

MattRix avatar Nov 14 '12 16:11 MattRix

Thank you, it worked perfectly.

tmuntaner avatar Nov 14 '12 21:11 tmuntaner

I got a basic prototype working well for physics of circles and boxes, I have no idea how to approach the complex polygon colliders though. Its still at https://github.com/tmuntan1/futile-physics.

tmuntaner avatar Nov 15 '12 13:11 tmuntaner

I think the complex polygons will have to be done by creating a custom mesh and passing it to a mesh collider. I'm not sure whether a flat mesh will work or whether it'll have to be "thick" in the z dimension.

MattRix avatar Nov 15 '12 18:11 MattRix

Sorry, I got tied up in something else for a while but I see that you have made some progress with your physics engine. Do you have any code that I can see on how to use your engine?

tmuntaner avatar Jun 28 '13 15:06 tmuntaner

Yeah, have a look at http://github.com/MattRix/TOJam8

MattRix avatar Jul 03 '13 11:07 MattRix