diff --git a/src/config.h b/src/config.h index e4451aa..447e4bf 100644 --- a/src/config.h +++ b/src/config.h @@ -20,7 +20,7 @@ #define ISOMETRIC_SKEW 0.3f #define WORLD_TO_ISO_SCALE 10.0f -#define VIEW_RUBBER_FOLLOW_SPEED 0.5f +#define VIEW_DYNAMIC_FOLLOW_SPEED 0.05f // Inputs #define JOYSTICK_DEADZONE 0.1f diff --git a/src/game/camera/tracking_view.cpp b/src/game/camera/tracking_view.cpp index 220ff60..aa356e7 100644 --- a/src/game/camera/tracking_view.cpp +++ b/src/game/camera/tracking_view.cpp @@ -94,19 +94,17 @@ void TrackingView::followTarget() } // Move view to place tracking-point at edge of area - auto deltaToDesiredView = normalize(vectorToTarget) * (distanceToTarget - freeMoveRadius); - moveCenter(deltaToDesiredView); + auto deltaToDesiredView = normalize(vectorToTarget); -// performHardFollow(); -// if (isTargetInArea(dynamicFollowArea)) -// { -// // Slowly push target back into free area -// performDynamicFollow(); -// } else -// { -// // Hard follow -// performHardFollow(); -// } + if (distanceToTarget <= dynamicFollowRadius) { + // Reduce delta to make it less jaring + deltaToDesiredView *= VIEW_DYNAMIC_FOLLOW_SPEED * (distanceToTarget - freeMoveRadius); + } else { + // Hard follow + deltaToDesiredView *= dynamicFollowRadius; + } + + moveCenter(deltaToDesiredView); } void TrackingView::moveCenter(sf::Vector2 delta)