Godot Version 4.7
Question
Hi, I’m trying to make a gamebar sorta like the stardew fishing minigame but I cannot get the colliders to work correctly for some reason. I have all monitoring/monitorable set to true and everything is on layer and mask 1. Im using the code below to determine when there is a collision, I’ve also tried area_entered/exited but that did not work either. sliderArea is an Area2D inside of an AnimatableBody2D and inside is a CharacterBody2D that the player moves with move_and_slide(). The code below is constantly returning true, even when they do not appear to overlap. If anyone can help me figure this out it would be greatly appreciated 
var onSlider onSlider = sliderArea.overlaps_body(inside)
could be anything from invalid scales set in the property inspector for the collision objects,
when you add a collision shape you should always configure its shape using the resource properties of the collision resource, and not by setting the scale of the object itself
also if you want an area to detect physics bodies (like a character body) use body_entered/body_exiting signals and not area_entered/area_exiting
and finally try to use signals over overlaps_body because that will be more performant
and if that also does not work then you can change your approach by using two variables to store a top and bottom position and checking if the character body 2d’s y position is within those bounds
something like
player.position.y < permissible_area.max and player.position.y > permissible_area.min
Firstly, I would make them on a separate layer. Say World is 1, Player is 2, Objects is 3 and UI Minigame is 4, just to rule out anything that may be colliding in the background. Just because something is drawn on top of something else, doesn’t mean a shape behind it can’t collide with it.
Like Master172 says, the bar you are controlling could be changed to a CharacterBody2D. This will simplify moving it around, and make signals easier. You would just have to decide how to limit its movement to stay within the minigame.
Then on your “Interaction Zone” let’s call it, use the signal “on body entered/exit” now that we are using a character body.
func _ready() -> void:
body_overlapping = false
func _process(_delta) -> void:
if body_overlapping:
do_desired_function()
func _on_body_entered(body: Node2D) → void:
if body is CharacterBody2D:
print ("Character Body entered: ", body.name)
body_overlapping = true
func _on_body_exited(body: Node2D) → void:
if body is CharacterBody2D:
print ("Character Body exited: ", body.name)
body_overlapping = false
func do_desired_function():
var points += 1