#The transform.y doesn't go under than 3.

1 messages · Page 1 of 1 (latest)

fresh turret
#
void Update()
        {
            if (noteData == null) return;

            float musicTime = GameManager.Instance.GetMusicTime();
            float t = (musicTime - (noteData.time - travelTime)) / travelTime;

            float y = Mathf.Lerp(spawnY, judgeLineY, t);
            transform.position = new Vector3(noteData.line * 1.5f, y, 0);

            if (y <= outOfScreenY)
            {
                notePool.ReturnNote(gameObject);
                noteData = null;
            }
            
            Debug.Log($"Note {name} y={y} (Transform.y={transform.position.y}) t={t}");
        }
Note Note(Clone) y=-3 (Transform.y=-3) t=4.148889
UnityEngine.Debug:Log (object)
Code.NoteBlock.Note:Update () (at Assets/Code/NoteBlock/Note.cs:48)

If t is higher than 3, then Transform.y must be under than -3. But it doesn't. who can fix it?

if you need github, then I can show.

obsidian cypress
#

MathF.Lerp expects a t value in range [0;1]. Any other value will get clamped to this range (3 will get clamped down to 1, value of judgeLineY will be returned). Either change up your logic or use MathF.LerpUnclamped