R0J0hound's Recent Forum Activity

  • link updated

  • Link updated.

  • RattyRat

    You could also look at another paid for box2d plugin. I think they have that feature there.

    A game engine from scratch is more appealing than unity. At least to me.

  • Stopping distance would be = (speed^2)/(2*deceleration)

  • I had a look around at some other implementations for buoyancy that can give some more ideas.

    https://github.com/lawrencelomax/Chipmu ... Buoyancy.c

    The damping force was calculated with the relative velocity of the part under water. I forgot to do that in the examples.

    The angular damping is proportionate to the inertia of the shape under water. Could give improved results.

    http://www.iforce2d.net/b2dtut/buoyancy

    Again it uses relative velocity for damping.

    It has a cool idea to do the damping per edge to give more realistic results.

    Also it shows ideas how to take the whole thing further with lift. Very interesting.

  • RattyRat

    You can't do that with the plugin, and modifying it to do so will have lots of caveats. The idea came up when I was making the behavior but I opted for making things easier to use. It's something best served by a ground up re-write and re-design of how it deals with the js library. I'm not really modifying or creating plugins or behaviors lately though. Lots of work for little gain imo. I have other more entertaining and interesting projects i'd want to do first, but if those succeed I may not be back.

    Anyways, the behavior manages the conversion of c2 coordinants to chipmunk coordinants, and vise versa. The complication is c2 uses the origin as the object center and chipmunk uses the center of mass (COM). To have multiple objects welded together they'd have a shared COM, and it would have to be updated every time things are moved with anything but the physics engine. There are other properties that would need to be updated as well. At least that's my thought.

    -cheers

  • i have an old example the you may be able to find that uses a JavaScript physics engine directly to do hand drawn shapes. The drawback is you have to do all physics objects that way. The behaviors don’t interact with it.

    There’s also a sold physics behavior that lets you do that. That’s all I know, I avoid buying stuff.

    A third way would be to modify one of the existing behaviors but this is out of scope to most.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I’m on my phone but offhand:

    The calculated area will be zero when there’s no overlap. So the forces will evaluate to zero too because they are multiples by the area.

    I just kind of threw the three examples together, but the idea is to just tweak the numbers in the equations. I think I tried something different for the chipmunk damping maybe that’s no good?

    The two behaviors have many differences. I made no effort to match them up.

  • All three examples just vary by the amount of linear damping, angular damping and amount the area affects the force. You can tweak all three to get things closer.

    For other shapes just add more image points, and make sure you place them in a clockwise order. Then in events 4 and 5 there are 4's, replace those with imagepointcount+1. You were halfway there.

    What do you mean connect things together? That would just be joints and is unrelated to the buoyancy here.

  • Here's my solution.

    1. Take the object polygon and slice it by the water level to get the polygon of the area underneath.

    2. calculate the area and center of that area.

    3. Apply a buoyancy force proportionate to the area and do it at the calculated center.

    4. Apply some damping to the object to slow it's velocity when in water. This corrects the bouncing.

    3 and 4 will differ depending on what you use. I tried event based physics, chipmunk and the physics behaviors.

    https://www.dropbox.com/s/5gllhncklyzsp ... .capx?dl=1

    https://www.dropbox.com/s/1b95mjd4viv8d ... .capx?dl=1

    https://www.dropbox.com/s/3539qrtyc0l7c ... .capx?dl=1

    I didn't try to get each to be identical, tweaking the numbers in the last event can adjust the result.

    A few notes:

    * To make the objects sink more apply a lower force.

    * damping is done by applying a force opposite a fraction of the velocity. Too high of damping can cause the object to actually speed up.

    * angular damping was a bit more tricky. I found more damping is needed than with linear damping. There also appear to be some better approaches but they add complexity and so far the results seem "good enough."

    Also as a reference, here is a list of the units the Physics behavior uses.

    math-and-physics_p821290?#p821290

  • The realistic way would be to find the area of the object under the water and apply a force proportional to that area, and from the center of that area up.

    As a simple example let’s look at a non rotating box.

    Area = box.width * clamp(box.bottom-water.top, 0, box.height)

    Apply force up with magnitude area

    In the general case with any shape with rotation you could take the polygon of the object, slice it by the water level, and find the area and average center of anything below. I forget if the physics behavior

    Let’s you apply a force at any point of the object but that should take care of any torque if it does. If it doesn’t then you can take the vector from the com to the point to apply the force and do a cross product with the force vector. Maybe some unit conversion would be needed, I don’t recall.

    It’s an interesting enough problem I may attempt an example capx over the weekend. The bulk of it will be finding the area under the water.

  • Hit enter, or right-click -> wrap selection.

R0J0hound's avatar

R0J0hound

Member since 15 Jun, 2009

Twitter
R0J0hound has 157 followers

Connect with R0J0hound