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 ISOMETRIC_SKEW 0.3f
|
||||||
#define WORLD_TO_ISO_SCALE 10.0f
|
#define WORLD_TO_ISO_SCALE 10.0f
|
||||||
|
|
||||||
#define VIEW_RUBBER_FOLLOW_SPEED 0.5f
|
#define VIEW_DYNAMIC_FOLLOW_SPEED 0.05f
|
||||||
|
|
||||||
// Inputs
|
// Inputs
|
||||||
#define JOYSTICK_DEADZONE 0.1f
|
#define JOYSTICK_DEADZONE 0.1f
|
||||||
|
|
|
@ -94,19 +94,17 @@ void TrackingView::followTarget()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move view to place tracking-point at edge of area
|
// Move view to place tracking-point at edge of area
|
||||||
auto deltaToDesiredView = normalize(vectorToTarget) * (distanceToTarget - freeMoveRadius);
|
auto deltaToDesiredView = normalize(vectorToTarget);
|
||||||
moveCenter(deltaToDesiredView);
|
|
||||||
|
|
||||||
// performHardFollow();
|
if (distanceToTarget <= dynamicFollowRadius) {
|
||||||
// if (isTargetInArea(dynamicFollowArea))
|
// Reduce delta to make it less jaring
|
||||||
// {
|
deltaToDesiredView *= VIEW_DYNAMIC_FOLLOW_SPEED * (distanceToTarget - freeMoveRadius);
|
||||||
// // Slowly push target back into free area
|
} else {
|
||||||
// performDynamicFollow();
|
// Hard follow
|
||||||
// } else
|
deltaToDesiredView *= dynamicFollowRadius;
|
||||||
// {
|
}
|
||||||
// // Hard follow
|
|
||||||
// performHardFollow();
|
moveCenter(deltaToDesiredView);
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackingView::moveCenter(sf::Vector2<float> delta)
|
void TrackingView::moveCenter(sf::Vector2<float> delta)
|
||||||
|
|
Loading…
Reference in a new issue