flame-engine / flame

A Flutter based game engine.
https://flame-engine.org
MIT License
8.98k stars 879 forks source link

docs(example): DraggableBox does not follow the cursor smoothly #3204

Closed ksokolovskyi closed 1 week ago

ksokolovskyi commented 1 week ago

Description

This PR makes the DraggableBox movement more smooth and predictable by: 1) adjusting FixtureDef and MouseJointDef parameters 2) setting the MouseJoint target to game.screenToWorld(event.deviceEndPosition) rather than event.localEndPosition

Fixes https://github.com/flame-engine/flame/issues/3203

The comparison recordings are presented below:

GearJointExample | BEFORE | AFTER | |----------|----------| |
PrismaticJointExample | BEFORE | AFTER | |----------|----------| |
PulleyJointExample | BEFORE | AFTER | |----------|----------| |
RopeJointExample | BEFORE | AFTER | |----------|----------| |

Checklist

Breaking Change?

Related Issues

ksokolovskyi commented 1 week ago

@spydon thanks for the review and merge!