Home Game Development unity – Adjust bounce coroutine arc to achieve greater/decrease level

unity – Adjust bounce coroutine arc to achieve greater/decrease level

0
unity – Adjust bounce coroutine arc to achieve greater/decrease level

[ad_1]

I’m utilizing a co-routine to make the participant in my 3D sport bounce. It’s not 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 period = 1;

whereas (time < period) {
    time += Time.deltaTime;
    float lerpVal = t / period;
    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 tremendous if you’re leaping someplace on the identical stage, nevertheless it does not look proper if you’re leaping to a better or decrease level from jumpFrom.

Any solutions on how I’d modify this?

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here