[Physics] Reduce swinging movement (friction joints)

I’m working on a fishing minigame and while swinging the rod I noticed that the swing movement was really accentuated.
After looking for suggestions online I came to the conclusion that I needed to try box2d’s friction joints, however I wasn’t not sure if those were supported in Defold.

swinging_fishing_rod

Do you have any suggestion on how to reduce the induced movement on the hook?

What I’ve tried so far:

  • Increase the hook mass (works for a couple of seconds but then it becomes even more accentuated because of the bigger inertia)
  • Try changing the damping values (this resulted on a weird looking scene where the objects looked like they were immersed in jelly, which makes sense)

Hmm, what kind of joints are you using and what values do you use?

Hi, thank you for the reply!
I’m using hinge joints, here’s the code I use to create them:

physics.create_joint(physics.JOINT_TYPE_HINGE, "/rod#collision_rod", "joint_rod_rope", vmath.vector3(0), "/rope#collision_rope", vmath.vector3(0,0,0))
local pos=vmath.vector3(0, -190, 0)
physics.create_joint(physics.JOINT_TYPE_HINGE, "/rope#collision_rope", "joint_rope_hook", pos, "/hook#collision_joint", vmath.vector3(0,0,0))

What values are you referring to? Mass, friction, gravity?
The mass of the hook is set to 100, the rope is 10. Those turned out to be the most realistic ones.

Here are my physics settings:

It looks like your hook is weighted heavily toward the end, have you tried adjusting that? If you had a simple ball instead of a long hook it wouldn’t be able to flip around like that, so my guess is it’s related to the balance of the hook.
Possibly you could also attach the line a little bit further down the hook so it’s closer to the center of mass. (Doing that too much would probably look wrong though.)

1 Like

Ross has a point. Try his suggestion. I’d also try changing the physics scale to a larger value. When I played around with springs I found that the result was more stable with a larger scale value.

1 Like

Thank you guys, I followed your suggestions and I managed to make it look better!
I ended up doing the following things:

  • Added a weight at the top of the hook. This balanced the hook itself as well as the rope.
  • Increased the damping values. (Especially the angular dumping on the hook).
  • Increased the gravity.

fishing_rod_defold

9 Likes