![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Kompaktive |
good day, everybody. I’m trying to make a game similar to pong, and I need to animate the paddle everytime the ball collides to it.
this is the paddle code.
func _physics_process(delta):
get_input()
position.x = clamp(position.x, 40, 140)
var collision = move_and_collide(velocity * delta)
if collision:
$AnimatedSprite.play()
The problem with move_and_collide()
is that it only plays the animation once it detect a collision WHILE moving. Is there anyway to set kinematicbody2d
collision detection to true
without moving? Or do I have to change the node type?
Hi,
What is the Node you use for the ball?
p7f | 2019-01-23 18:16
Have you looked at the test_move()
function? You can take a transformation, feed it into this function, and test whether the KinematicBody2D
collides without moving anything.
Ertain | 2019-01-23 19:05
The paddle and the ball use kinematicbody2D
Kompaktive | 2019-01-23 23:21
I read the document and test_move()
might be what I wanted, but I have no idea how to use it.
Kompaktive | 2019-01-23 23:26