CharacterBody2d & RigidBody2d Collision detection

Godot Version 4.2.1

Question

Ball: RigidBody2d
Rectangle: CharacterBody2d
Both have collisionShape2d

I have an _on_body_entered func inside the ball script that prints “working” when collision is detected. Working is only being printed when contact is made with the corner of the rectangle and not the faces.

End goal would be to apply forces to the ball based on the contact made with the rectangle. Issue is current collision is not detected on the faces in order to then add that code.

Code is below for both entities. I would post video but as a new user I am unable to.

Rectangle code

extends CharacterBody2D

#Button Variables
@export var SPEED: int = 40000

#Touch Variables
var dragging = false
var offset = Vector2(0,0)

func _physics_process(delta: float) -> void:
    #Button Movement
    var direction = Input.get_axis("Left", "Right")
    if direction:
        velocity.x = direction * SPEED * delta
    else:
        velocity.x = 0
    #Touch Movement
    if dragging:
        var newPos = get_global_mouse_position() - offset
        position = Vector2(newPos.x,280)
    move_and_slide()
        
func _on_button_button_down() -> void:
    dragging = true
    offset = get_global_mouse_position() - global_position
    
func _on_button_button_up() -> void:
    dragging = false

Ball Code

extends RigidBody2D

var velocity = Vector2(350, 350)

func _physics_process(delta: float) -> void:
    
    var collisionInfo = move_and_collide(velocity * delta)
    if collisionInfo:
        velocity = velocity.bounce(collisionInfo.get_normal())
        
        
func _on_body_entered(body: Node) -> void:
    if body.is_in_group("Player"):
        print("working") 

Have you made sure the Rectangle is in fact in group “Player”? Have you enabled contact_monitor and set max_contacts_reported high enough on the Ball?

Thanks for the reply!

Yes the rectangle is In Group player.

The collision is detected on the rectangles corners. So that part is working.

Contact monitor is enabled. Also Max contacts reported is set to 1. Should that be higher?

Huh, weird! I cannot reproduce that. Can you share an example project?

As a new user im unable to upload my videos showing this.

How exactly would I share the project?

I can share this discord link that goes to a help post I made there that has the videos and code for the project: