[ad_1]
I’m utilizing a co-routine to make the participant in my 3D recreation leap. 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 superb in case you are leaping someplace on the identical stage, but it surely does not look proper in case you are leaping to the next or decrease level from jumpFrom
.
Any recommendations on how I would modify this?
[ad_2]