0 votes

I have two RigidBody2Ds - player and the ball. I need them to be RigidBody2Ds because I rely on the godot's physics engine to handle collisions/bounces/rotations and so on.

However, there's one thing I want to control manually - I want to set ball's velocity RIGHT AFTER the collision with the player. Generally, it's not a problem to detect a collision (I can use body_entered/body_exited signals or contact monitor) and setting ball's velocity (I can do it using apply_impulse or _integrate_forces).

The problem is no matter what combination of those methods I use I can't sync it with the physics engine. There's a noticeable jitter when ball's velocity is high because the velocity is set one physics frame after the collision. This is what velocity looks like when printed out in _integrate_forces:

  1. Velocity before collision
  2. Velocity after collision, calculated by the engine
  3. Velocity that I actually want to set

Is there any way to tackle it?

EDIT: I want collisions between player and ball to work as usual but let the player control the direction and speed of the ball with a kick whenever he wants.

in Engine by (27 points)
edited by

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.