Dynamic target following
This commit is contained in:
parent
8816cedca4
commit
1fcd4cd80c
2 changed files with 11 additions and 13 deletions
|
@ -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
|
||||
|
|
|
@ -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<float> delta)
|
||||
|
|
Loading…
Reference in a new issue