I'm having difficulty making a RigidBody2D move with a mouse click

Godot Version

4.2

Question

I have created a Node2D with a RigidBody2D as a child. I am trying to create a system where you can click a marble which would roll it. Here is my script which is attached to the RigidBody2D:

func _input_event(viewport, event, shape_idx):
if event is InputEventMouseButton and event.is_pressed():
if event.button_index == MOUSE_BUTTON_LEFT:
print(“Click detected”)
var click_position = event.position
var direction = (click_position - global_position).normalized()
apply_impulse(Vector2.ZERO, direction * 500)

The click is being detected and I can also print out the click position and direction, so everything seems to be registered correctly. The RigidBody2D simply won’t move though.

I’ve set gravity to 0 as this is a top down game.

I’ve set the mass to be very light, I can’t see anything being locked and I’ve changed 500 to much higher numbers.

I’ve even thrown this problem at ChatGPT and it can’t seem to identify the issue

The first argument of the apply_impulse() function should be the direction of the impulse. You have provided Vector2.ZERO, meaning the impulse is basically nothing.
Change it to simply this:

apply_impulse(direction * 500)

I will try this, thanks. I used Vector2.ZERO because I thought that meant the impulse would go towards the centre of the circle rather than the edge at a weird angle.