Area2D seems to be slightly delayed in getting collisions

Godot 4.2.2

I’m implementing some pretty simple 2D portals, and they work pretty much as intended except for the fact that the area 2D handling the entering of the portal seems to detect after the player hits the ground rather than as soon as they enter (by maybe a couple of frames). I figure this is the case because if there is either no ground below the portal or its high enough off the ground, velocity is conserved as expected. Here is the code for one of the portals, there are 2 per prepackaged scene for them but the code is identical, only difference is they reference the other portal.

extends Area2D

var direction = Vector2.ZERO

func _ready():
direction = Vector2(cos(self.global_rotation), sin(self.global_rotation))

func _on_body_entered(body):
if body is CharacterBody2D:
body.global_position = %Exitpos1.global_position
body.velocity = body.velocity.length() * %Portal.direction


Is there some way I could force it to update the moment the body enter? Am I missing something about area2Ds? Any suggestion is appreciated.

If the Area2D is too close to the other body that stops the CharacterBody2D then there’s not a lot you can do. You can try lowering the CharacterBody2D.safe_margin property which may help a bit.

You may also want to use CharacterBody2D.get_real_velocity() instead of CharacterBody2D.velocity