I want a kinematic body to be limited within the bounds of a circle, which I've done with this function:
func circle_limits(radius: float, center: Vector2, location: Vector2, pull_force: float):
var distance = center.distance_to(location)
if distance > radius:
var origin_to_object = (location - center) * (radius / distance)
return lerp(location, center + origin_to_object, pull_force)
This works how I want it to, but since I'm using the value to directly manipulate the position of my player, it doesn't apply any collisions when limiting the movement, causing the object to go through walls. Is there any way to use this value to limit the player within the confines of the circle while still applying collisions?