Freeze and release RigidBody2D in Area2D or on Kinematic2D

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By FeyGaming

Hi guys,

I’ve read many articles and the documentation in order to get the RigidBody2D to do what i want.

How is it possible to create a magnetic field like in a breakout game?

I get my ball stuck on the paddle and I can release it, but when my ball is stuck, i can’t move my paddle OR my ball doesn’t move with my paddle…

“”
if body.get_name() == “Player” and Input.is_action_pressed(“debug_key”):
emit_signal(“clicked”, self)
mode = RigidBody2D.MODE_STATIC
held = true
if held:
global_transform.origin = body.get_node(“Anchor”).get_global_position()
if Input.is_action_pressed(“go_ball”):
held = false
mode = RigidBody2D.MODE_CHARACTER
set_linear_velocity(velocity)
“”

And my ball only get centered on my paddle with:

“”
global_transform.origin = body.get_node(“Anchor”).get_global_position()

“”
I want my ball stuck at the Position who it enters

Thanks a lot