RigidBody2d ball not fully affected by gravity_point Area2D

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

I’m constructing a “ping-pong” paddle.

I would like to create an area behind the paddle that interacts with the RigidBody2D ball on the field, and if caught inside, it will redirect it back out in front of the player.

I set an Area2D with gravity point enabled, gravity vector of (1,0) (to shoot to the right) a gravity value of 1024 and 5 damping.

The damping itself does work bringing it down to minimum speed allowed on the ball (set inside the ball’s integrated forces) but no directional change occurs.

  • Project settings has removed default 2d damping but allowed gravity with a 0,0 gravity vector to not cause the ball to fall to the bottom of the screen.
  • The rigidbody2d ball itself clamps to a max and min speed which works fine within integrated forces method.
  • No gravity appears to be getting applied
  • I attempted to enable contacts monitoring on the ball to no effect, damping still works so the area2d is still applying an expected effect.

Any suggestions on how to do this? I also realize I’ll have to contend with the ball passing through the player’s kinematic collision when having to go through there but I haven’t thought that far yet



:bust_in_silhouette: Reply From: BenVella

So the solution turns out is what I did, just higher values.

  • I returned the ball’s mass to the original value because I noticed it was set higher due to previous changes, which made it heavier for the physics engine and more sluggish to move / be influenced by other objects.
  • Gravity scale was returned to one, no need to crank it out any further.
  • The player’s vacuum ability had its gravity cranked to the maximum (1024)
  • The Area2D containing the collision shape was moved to the edge of the screen as the target of the ball, and the collision shape was moved back over the player’s sprite to apply the influence there. This allows the ball to trigger on collision and shoot towards the opposing edge of the screen.

The upside to me messing these settings up is I discovered I can freeze the rigidbody ball with maximum linear damping, and that’s a cool new ability to implement, which was done in 5 minutes flat!