Im working on a tank game where bullets are relected off of walls. The formula for a relfection is r=d−2d⋅n∥n∥2n where d is the incoming vector and n is the normal of a wall. My bullets stick to the walls and then "bounce" off at the corners; an undesirable effect. Im honestly questioning my formula implementation at this point.
func collision(): for i in get_slide_count(): var collision = get_slide_collision(i) if collision.collider.is_in_group(globals.wall_group): var normal = collision.normal velocity = velocity - ((2 * velocity.dot(normal)) / normal.length_squared()) * normal rotation = velocity.angle() + PI
if i use the is_on_wall function and simply negate the velocity this does produce a bouncing effect but not a correct one. I still need the normal.
I orignally used rigid bodies as seen in the image. But i have switched to kinematic bodies.