GameDevWannaBe you made me worry and doubt myself for a second there, had to go and create a project just to test this.
the problem is with your code, godot collisions work correctly when 2 or more nodes collide with both on_area_entered and on_body_entered in godot 4.2.2:
your collisions should be handled from ONE SIDE ONLY.
either put the on area entered on the player or on the coin, NOT BOTH.
if you are trying to do a cell simulator, then put the same code in both objects.
func _on_area_2d_body_entered(body):
var player_scale = player.scale.x
var food_scale = body.scale.x
print("[Player]:Body name : ",body.name)
print("[Player]: " + str(food_scale) + " " + str(player_scale))
if food_scale > player_scale:#< ----- HERE'S YOUR PROBLEM
print("[Player]:Died...")
else:
kills += 1
print("Check kills:",kills)
score.text = str(kills)
scale.x += weight
scale.y += weight
in here you are testing player size against coin size to determine if something will happen. use a different system, create a variable in player to handle this. when two collisions happen at the same frame, it might be waiting for the frame to end to update physics.
func _on_area_2d_area_entered(area):
var player_scale = player.scale.x
print("[Food]:Player : " + str(player_scale) + " Food : " + str(food_scale) + "!")
if player_scale < food_scale:
print("[Food]:Player Got Killed")
get_tree().reload_current_scene()
else:
queue_free()
in here the coin is killing itself after doing the same test.
there should only be ONE on_body_entered in player to handle everything:
var player_scale : float = 1.0
func _ready():
player_scale = player.scale.x
func _physics_process(delta):
player.scale = Vector2(player_scale, player_scale)
func _on_area_2d_body_entered(body):
var food_scale = body.scale.x
print("[Player]:Body name : ",body.name)
print("[Player]: " + str(food_scale) + " " + str(player_scale))
if food_scale > player_scale:
print("[Player]:Died...")
get_tree().reload_current_scene()
else:
kills += 1
print("Check kills:",kills)
score.text = str(kills)
player_scale += weight
body.queue_free()