How to bounce a ball with a character correctly. Which Nodes to use.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By osemoka

Hi!
I’m pretty new to Godot and it’s my first post.
I can move around the Engine as an app, understand where are the elements etc., but I have problems with understending the physics.

I want to create simple scenario when a character is standing on the floor, can move left, right and jump to bounce a ball on collision. The bounce direction would be based on the collision point of CapsuleShape2D
I created CharacterBody2D with its default script for character and floor with StaticBody2D node. It can move and jump with no problems. I assumed that CharacterBody2D Node is suited for this kind of player behaviour.

The problem starts with the ball implementation. What type of Node should the ball be?
Firstly I though about RigidBody2D, so it can be affected by engine physics, but it got problematic. The ball is moving, teleporting, stopping my character on contact.

Also the problem is with ball applying impulse, looks like it only gets it every other time (?).

Should the ball be another kind of a Node ? Or is it just a matter of correct code?
Can you point me at the right direction here? Types of Nodes for Player and Ball would be a good start. Then if possible some code tips. Function to use.

I want to mimic the behaviour of Blobby Volleyball game.

My poor codes for Ball and Character:

:bust_in_silhouette: Reply From: Zylo_X

here is a guide step by step of how to make a bounce ball in godot with good explanation
i hope that helps
you should take in your consider that this tutorial is for godot3.x
so there is some changes like kinematicBody2D is now CharacterBody2D and so on
you may have to change some codes ( for example now we typemove_and_collide () with no parameters to pass in )

Bouncing off staticbody is easier. It just bounces of it when we apply motion. I saw his video before but it doesn’t answer my question.
My question is regarding how to bounce the rigidbody of characterbody on Collison without being affected by its physics.

The desired behavior is similar to blobby volleyball from decades ago.

osemoka | 2023-03-29 22:30