+Add : GIT LFS & fully functional infinite stair
This commit is contained in:
@@ -246,15 +246,16 @@ namespace Unheimlich.World.Environment
|
||||
{
|
||||
if (_playerTransform == null) return;
|
||||
|
||||
float error = _playerTransform.position.y - _triggerCenterWorldY;
|
||||
float rawTarget = Mathf.Clamp(error * _correctionGain, -_maxScrollSpeed, _maxScrollSpeed);
|
||||
float error = _playerTransform.position.y - _triggerCenterWorldY;
|
||||
float rawTarget = Mathf.Clamp(error * _correctionGain, -_maxScrollSpeed, _maxScrollSpeed);
|
||||
|
||||
// Only allow speed in the direction that moves the tower correctly.
|
||||
// Going up (entered from below): tower must descend → speed >= 0.
|
||||
// Going down (entered from above): tower must ascend → speed <= 0.
|
||||
float targetSpeed = _enteredFromBelow
|
||||
? Mathf.Max(rawTarget, 0f)
|
||||
: Mathf.Min(rawTarget, 0f);
|
||||
bool towerHasMoved = _enteredFromBelow
|
||||
? _towerRoot != null && _towerRoot.localPosition.y < -0.05f
|
||||
: _towerRoot != null && _towerRoot.localPosition.y > 0.05f;
|
||||
|
||||
float targetSpeed = towerHasMoved
|
||||
? rawTarget
|
||||
: (_enteredFromBelow ? Mathf.Max(rawTarget, 0f) : Mathf.Min(rawTarget, 0f));
|
||||
|
||||
_scrollSpeed = Mathf.SmoothDamp(_scrollSpeed, targetSpeed, ref _scrollSpeedVelocity, _scrollSmoothTime);
|
||||
}
|
||||
@@ -271,12 +272,6 @@ namespace Unheimlich.World.Environment
|
||||
? Mathf.Max(pos.y, _limitLocalY)
|
||||
: Mathf.Min(pos.y, _limitLocalY);
|
||||
|
||||
// Clamp to the origin — slot 0 must never move past its starting position.
|
||||
// Going up: tower can only descend from 0. Going down: tower can only ascend from 0.
|
||||
pos.y = _enteredFromBelow
|
||||
? Mathf.Min(pos.y, 0f)
|
||||
: Mathf.Max(pos.y, 0f);
|
||||
|
||||
_towerRoot.localPosition = pos;
|
||||
}
|
||||
|
||||
@@ -285,8 +280,8 @@ namespace Unheimlich.World.Environment
|
||||
if (_towerRoot == null) return;
|
||||
|
||||
bool reached = _enteredFromBelow
|
||||
? _towerRoot.localPosition.y <= _limitLocalY
|
||||
: _towerRoot.localPosition.y >= _limitLocalY;
|
||||
? _towerRoot.localPosition.y <= _limitLocalY // going up, tower descended enough
|
||||
: _towerRoot.localPosition.y >= _limitLocalY; // going down, tower ascended enough
|
||||
|
||||
if (reached)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user