Topic was automatically imported from the old Question2Answer platform.
Asked By
Letheed
Old Version
Published before Godot 3 was released.
Hi! I’m new to godot. Can anyone help me figure out what I’m doing wrong: if the paddle moves during the rebound, the ball slows down or even crawls to a stop.
Setup is standard: ball=RigidBody2D, paddle=KinematicBody2D.
I’m using the Godot 3 alpha.
Your problem is not the ball slowing down but that is a rigid body (not recommended if you want to have control over it) and your paddle is a kinematic body that hits the ball with the same body that moves with move.
While using move, that body does overlap prevention and if the “rigid” ball hits, the kinematic separate from the overlapping situation, that leaves the ball collision in a weird state, where it was supposed to be hitting and the body moved.
To solve the kinematic part, your ball should be on a place where hits a kinematic body who does not care about overlaps.
You can move the paddle with set_pos (losing some possible use of overlap prevention) or add a child kinematic body with the hitbox to touch the ball like this:
paddle (kinematic body moved by move, not ball mask)
|-hitbody (kinematic body on layer detected by the ball)
Thank you for your answer, I could never have figured that out.
Using layers with two bodies worked perfectly!
I’m a bit surprised that I’ve not found any info about this in any of the tutorials and documentations that I’ve read. That seems like it would be a common beginner problem.
Letheed | 2017-08-21 18:16
It is a common beginner problem, yes, and you may find many similar questions here (just search for “paddle”).
The first issue is when “pong” and “breakout” are shown as examples of simple games, with modern engines is not the case because these need a lot of collision control.
Runners and shmups are more easy and quick to make.