autonomnom / Water-on-Mars

meeeeeeow
0 stars 0 forks source link

Jittering when camera can't decide which way to go, need states? #4

Closed autonomnom closed 8 years ago

autonomnom commented 8 years ago

Code so far:

void FixedUpdate () {

    adjustUpDist();
    targetPosition = foollow.position + foollow.up * camUp - foollow.forward * camDistance;
    if (zoom) { targetPosition = Vector3.Lerp(targetPosition, targetPosition - foollow.up * 5f, 1.1f); }
    body.position = Vector3.Lerp(transform.position, targetPosition, Time.deltaTime * smoothy1);
}

void adjustUpDist() {

    if (checkEyeContact() || zoom) {

        camDistance = Mathf.Lerp(camDistance, 11, lerpFactor); ;
        camUp = Mathf.Lerp(camUp, 10, lerpFactor / 3);
    }
    else {
        camDistance = Mathf.Lerp(camDistance, _camDistance, lerpFactor);
        camUp = Mathf.Lerp(camUp, _camUp, lerpFactor);
    }

Problem is, that if the obstacle is straight behind the camera while looking in the direction of the identity, it is in a constant forward/backwards state = jittering.

jitteringtruefalseswitchtingeachframe

Maybe this is to be solved with different states depending on the distances between the camera and the obstacles?

autonomnom commented 8 years ago

Fixed the jittering, new issue incoming.