How to make a rotating platform:
1. Create a world.
2. Create a body that acts as your platform.
3. Create an anchor for you platform.
4. Create a revolute joint connecting the anchor and platform.
5. Add shapes to your platform.
This turns into a mess when you reach upwards of 2 platforms.
How to make objects collide:
1. Set collision callbacks.
2. Set shape data for each shape you want to collide.
3. Use an if statement: if (shape1 = your first shape and shape2 = your second shape) OR if (shape1 = your second shape and shape2 = your first shape)
4. Figure out which bodies the shapes apply to so you can make them react properly.
No wonder why Tilt was such a glitchy mess.
Seriously, this is ridiculous. Can't you use some other, simpler physics engine?
love.physics is the most frustrating thing ever.
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: love.physics is the most frustrating thing ever.
I think this boils down to the fact that physics aren't simple. I believe (and this is my personal opinion) that all the physics engines will have more or less the same concepts.
Certainly Box2d has something to do with the "glitchiness"; the version used in LÖVE is outdated, and that shows sometimes.
The "messiness", on the other hand, is ... likely not Box2D's fault. I hope you don't take this the wrong way - writing clean code is very difficult.
Code: Select all
No wonder why Tilt was such a glitchy mess.
The "messiness", on the other hand, is ... likely not Box2D's fault. I hope you don't take this the wrong way - writing clean code is very difficult.
When I write def I mean function.
- Taehl
- Dreaming in associative arrays
- Posts: 1025
- Joined: Mon Jan 11, 2010 5:07 am
- Location: CA, USA
- Contact:
Re: love.physics is the most frustrating thing ever.
Unfortunately, physics are a very, very messy thing... If you want something cleaner, it may be a good idea to brew up your own nonrealistic physics engine, or to use one someone else has already made like Fizz or Hardon Collider.
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
- BlackBulletIV
- Inner party member
- Posts: 1261
- Joined: Wed Dec 29, 2010 8:19 pm
- Location: Queensland, Australia
- Contact:
Re: love.physics is the most frustrating thing ever.
I agree with kikito, physics is complicated. To makes things easier for myself, I wrote the PhysicalEntity and PhysicalWorld classes (part of my personal framework); they make life much easier for me.
Box2D certainly has a number of quirks, like needing the delta time it gets to be limited (although you'll find that problem no matter where you do physics).
Box2D certainly has a number of quirks, like needing the delta time it gets to be limited (although you'll find that problem no matter where you do physics).
Just for clarification, Hardon Collider only deals with collision, not resolution.Taehl wrote:If you want something cleaner, it may be a good idea to brew up your own nonrealistic physics engine, or to use one someone else has already made like Fizz or Hardon Collider.
Re: love.physics is the most frustrating thing ever.
This sounds like an opportunity for another library
Re: love.physics is the most frustrating thing ever.
It may be true that physics tend to be complicated, and writing clean code may be hard, but I feel like Box2D makes things a lot more verbose and painful than they need to be. It pretty much forces you to have huge amounts of code. Since shapes are independent from bodies, that pretty much guarantees that you're going to have lots of tables and for loops, especially in collisions. Also, in collisions, you have to specify either order of the shapes colliding. And we can't just have bodies collide, we have to have shapes collide. So you have to write extra code to figure out which one's the right body.
If I could use some more lightweight library for Tilt, I would, but I don't know of anything else that would give me nice realistic physics. Does anyone have experience with some other engine like Chipmunk Physics? I'm not sure there's a Lua binding for that one, but I may as well know if it's good before I bother looking.
Also, BlackBullet, I'll look at your scripts there.
If I could use some more lightweight library for Tilt, I would, but I don't know of anything else that would give me nice realistic physics. Does anyone have experience with some other engine like Chipmunk Physics? I'm not sure there's a Lua binding for that one, but I may as well know if it's good before I bother looking.
Also, BlackBullet, I'll look at your scripts there.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: love.physics is the most frustrating thing ever.
Shape:getBody?Tesselode wrote:So you have to write extra code to figure out which one's the right body.
Help us help you: attach a .love.
- BlackBulletIV
- Inner party member
- Posts: 1261
- Joined: Wed Dec 29, 2010 8:19 pm
- Location: Queensland, Australia
- Contact:
Re: love.physics is the most frustrating thing ever.
Well that's always the way it is with anything in the programming world: doing more stuff for you makes it easier, but more restrictive. For example, machine code does nothing for you, allowing you to do anything, but at the cost of making it near impossible to code in. While on the other hand, something more higher level like Lua, does more for you, meaning it's more restrictive, but so much easier.Tesselode wrote:It may be true that physics tend to be complicated, and writing clean code may be hard, but I feel like Box2D makes things a lot more verbose and painful than they need to be. It pretty much forces you to have huge amounts of code. Since shapes are independent from bodies, that pretty much guarantees that you're going to have lots of tables and for loops, especially in collisions. Also, in collisions, you have to specify either order of the shapes colliding. And we can't just have bodies collide, we have to have shapes collide. So you have to write extra code to figure out which one's the right body.
If we didn't have separate shapes in Box2D, the types of collision you could do would be very limited: the most complex collision you could do is an eight point polygon. However, because shapes are separate, we have multiple shapes attached to one body, allowing for much more complex shapes of objects. For example, we could make the shape of a human out of many polygons.
Cool. You'll need to adapt them to suit your needs of course, unless you want to use the framework's Entity/World structure.Tesselode wrote:Also, BlackBullet, I'll look at your scripts there.
Re: love.physics is the most frustrating thing ever.
I don't understand why you have to use joints in this case.Tesselode wrote:1. Create a world.
2. Create a body that acts as your platform.
3. Create an anchor for you platform.
4. Create a revolute joint connecting the anchor and platform.
5. Add shapes to your platform.
I assume your platforms are not moving so you can just create static shapes (whose density/mass is 0).
Static shapes remain stationary even after a collision.
Step 2 is optional.Tesselode wrote:1. Set collision callbacks.
2. Set shape data for each shape you want to collide.
3. Use an if statement: if (shape1 = your first shape and shape2 = your second shape) OR if (shape1 = your second shape and shape2 = your first shape)
4. Figure out which bodies the shapes apply to so you can make them react properly.
Regarding steps 3 and 4: maybe you can have general shape 'types'
Box2D is a pretty good engine.Tesselode wrote:Seriously, this is ridiculous. Can't you use some other, simpler physics engine?
Stick with it man, and you'll learn how it works.
Re: love.physics is the most frustrating thing ever.
Yes, this is correct.BlackBulletIV wrote:However, because shapes are separate, we have multiple shapes attached to one body, allowing for much more complex shapes of objects. For example, we could make the shape of a human out of many polygons.
Suppose each shape had the properties of a body (velocity/angle, damping etc)
What would happen if you attached 2 shapes together and (for example) you want to move them together to the left.
At what point would you apply an impulse/force?
1.To prevent resulting torque you would have to manually calculate the center of mass of the 2 shapes that you have attached together.
2.What would be the magnitude of force/impulse that you are going apply? You would have to manually calculate the magnitude based on the masses of the two shapes.
Basically the body class saves you this and many similar headaches.
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 4 guests