Vector2 bouncing off ScreenHitbox and other CircleHitbox

Viewed 123

This question could be asked to any math wizard, but I am playing around in flame( loads of fun ), so I allow myself to ask it here.

My math is rusty but I have tried using reflect and normalized, but I am way off here. Can you help, and maybe give a direction for both ScreenHitbox & CircleHitbox.

I have CircleHitbox and a collision:

  @override
  void onCollisionStart(
    Set<Vector2> intersectionPoints,
    PositionComponent other,
  ) {
    super.onCollisionStart(intersectionPoints, other);
        if (other is ScreenHitbox) {
          // velocity.reflect(other.position.normalized());
          // velocity.reflect(other.size.normalized());
       velocity.reflect(intersectionPoints.first.normalized());
      // return;
    }
  }

Update: looking for normal on the collision?

enter image description here

0 Answers
Related