Friday, November 4, 2022
HomeGame Developmentunity - Regulate leap coroutine arc to succeed in increased/decrease level

unity – Regulate leap coroutine arc to succeed in increased/decrease level


I’m utilizing a co-routine to make the participant in my 3D sport leap. It isn’t a platformer and these jumps are all pre-defined (you hit a set off that tells you the place you’ll land)

Coroutine: (given jumpFrom and jumpTo vector3s)

float time = 0;
float length = 1;

whereas (time < length) {
    time += Time.deltaTime;
    float lerpVal = t / length;
    Vector3 currentPos = Vector3.Lerp(jumpFrom, jumpTo, lerpVal);
    currentPos.y += 0.25f * Mathf.Sin(Mathf.Clamp01(lerpVal) * Mathf.PI); <-- arc it barely
    remodel.place = currentPos;
    yield return null;    
}

This works nice if you’re leaping someplace on the identical degree, but it surely does not look proper if you’re leaping to a better or decrease level from jumpFrom.

Any options on how I would regulate this?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments