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