Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | expensne |
Hello!
I have a question regarding the mouse-movement. I’m new to Godot and trying to make a breakout clone but I’m stuck. Here is the code I use to move the paddle:
func process_mouse():
var target = get_viewport().get_mouse_position().x
if position.x < target:
if not test_move(Transform2D(transform), Vector2(1, 0)):
position.x = target
elif position.x > target:
if not test_move(Transform2D(transform), Vector2(-1, 0)):
position.x = target
It collides with the surrounding collision box as long as you move the mouse “normal”; if you move the mouse pretty fast the paddle moves inside the collision box and gets stuck like this:
Does anyone have an idea where the problem is?