Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | MrBucket |
So the code below does not work since velocity gets set to 0 when you are on the left side of the paddle, and I would like to know how to make it so it will still have a smooth transition but still follow the mouse. Thanks.
extends Control
var velocity : float = 1
func _ready():
pass
func _process(delta):
print(velocity)
if $Paddle.position.x < get_viewport().get_mouse_position().x:
if velocity == 0:
velocity += 1
if velocity > 3:
velocity = 3
$Paddle.position.x += velocity
$Paddle.position.x += velocity
velocity += velocity / 30
elif $Paddle.position.x > get_viewport().get_mouse_position().x:
if velocity == 0:
velocity -= 1
if velocity < -3:
velocity = -3
$Paddle.position.x += velocity
velocity -= velocity / 30
Also sorry for it not being formatted, every time I pasted it kept not putting it in the code block and instead making it normal text
MrBucket | 2022-08-21 23:36