Wednesday 15 August 2012

c# - Camera Lerp seems to be incrementing every loop -



c# - Camera Lerp seems to be incrementing every loop -

i have 7 positions iterate between , have difference on x axis of 4.5 position0 = 0, position1 = 4.5 & position = 9, on , forth.

however, appears when go position0 position1, x continues grow 4.5. iterate through array works increases 4.5 every frame. doing wrong?

void start () { _positionarray[0] = position0; _positionarray[1] = position1; _positionarray[2] = position2; _positionarray[3] = position3; _positionarray[4] = position4; _positionarray[5] = position5; _positionarray[6] = position6; endposition = position0; } public void changedestination() { if (_leapmanager.swipeperformed) { swipedirection = _leapmanager.swipedirection; if (swipedirection == "left" && posinarray >= 0 && posinarray < 5) { debug.log("called"); posinarray++; endposition.position = _positionarray[posinarray].position; } else if (swipedirection == "right" && posinarray <= 5 && posinarray > 0) { posinarray--; endposition.position = _positionarray[posinarray].position; } } } // update called 1 time per frame void update () { transform.position = vector3.lerp(transform.position, endposition.position, speed * 3.0f * time.deltatime); }

c# unity3d

No comments:

Post a Comment