Area2D Collision to translate new vector based on rotation of collider

Godot Version

Godot 4.4.1 Stable

Question

I am working on a 2d pinball style game right now where i’d like the ball to collide with various physical objects and be affected by them. The one i’m stuck on right now is a slingshot. The slingshot is indicated by a triangle with a white inset triangle at the top corner to indicate direction of travel. The ball collides with the slingshot object, should be able to physically pass through the slingshot object but have it’s direction of travel vector adjusted to reflect the “top” face of the slingshot object based on it’s rotation.

Currently both the ball and the slingshot objects have area2d objects with collision shapes, layer masks and node groups assigned. Collision works between the two, but the slingshot object physically gets in the way of the the pinball moving in the direction of the top corner and even when it wasn’t it is not deflecting to the correct direction.


func _on_epu_collider_area_entered(area: Area2D) -> void:
	print("ball area2d entered")
	if area.is_in_group("Slingshot"):
		print("area is in group slingshot")
		dir = slingShot_Directions().normalized()

func slingShot_Directions():
	print("slingshot directions method entered successfully.")
	print("Direction going into the method is... " + str(dir))
	var slingshotDirection = dir.rotated(-$"../SlingshotEPU".rotation)
	print("New Direction after slingshot is... " + str(slingshotDirection)+". Slingshot rotation was " + str($"../SlingshotEPU".rotation))
	self.speed = speed + 50
	return slingshotDirection

You could try disabling the physics body’s collider for your slingshot. Then your other object can travel through it and interact with the area. That is assuming that the areas are children of actual physicsbody objects.

Could you post pictures of the slingshot and ball sceentrees?