Whats the best way to create a paddle for a Air Hockey Game?
I'm using a rigid body and here's my current code. But it looks really ugly when playing, because it moves only after the distance to player is bigger than 20 px. And if I remove that distance check, its starts to bounce on that point, like jittering.
extends RigidBody2D
const SPEED = 2000
var destination = null
func _integrate_forces(_state):
if destination != null:
var direction = (destination - global_position).normalized()
var distance_to_player = global_position.distance_to(destination)
if distance_to_player > 20:
linear_velocity = direction * SPEED
elif distance_to_player > 3:
linear_velocity = direction * SPEED * 0.20
else:
linear_velocity = Vector2.ZERO