setTransform method

void setTransform(
  1. Vector2 position,
  2. double angle
)

Set the position of the body's origin and rotation. This breaks any contacts and wakes the other bodies. Manipulating a body's transform may cause non-physical behavior. Note: contacts are updated on the next call to World.step().

Implementation

void setTransform(Vector2 position, double angle) {
  assert(!world.isLocked);
  transform.q.setAngle(angle);
  transform.p.setFrom(position);

  sweep.c.setFrom(Transform.mulVec2(transform, sweep.localCenter));
  sweep.a = angle;

  sweep.c0.setFrom(sweep.c);
  sweep.a0 = sweep.a;

  final broadPhase = world.contactManager.broadPhase;
  for (final f in fixtures) {
    f.synchronize(broadPhase, transform, transform);
  }
}