public bool releasedJumpEarly = false; //if player is doing a partial jump // Use this for initialization void Start() { velocity = new Vector2(0, 0); controller = GetComponent <MoveController2D>(); ComputeGravityAndJumpHeight(); ComputeWalkAcceleration(); }
public void Update(MoveController2D target, float lookAheadDstY) { Bounds targetBounds = target.myCollider.bounds; float shiftX = 0; if (targetBounds.min.x < left) { shiftX = targetBounds.min.x - left; } else if (targetBounds.max.x > right) { shiftX = targetBounds.max.x - right; } left += shiftX; right += shiftX; float shiftY = 0; if (targetBounds.min.y < bottom) { shiftY = targetBounds.min.y - bottom; } else if (targetBounds.max.y > top) { shiftY = targetBounds.max.y - top; } if (target.collisions.below && InputController.GetInstance().GetDirectionLookaround() != 0) { if (InputController.GetInstance().GetDirectionLookaround() > 0) { // hoch gucken shiftY = (targetBounds.max.y + lookAheadDstY + (top - bottom)) - top; } else { // runter gucken shiftY = (targetBounds.min.y - lookAheadDstY - (top - bottom)) - bottom; } } top += shiftY; bottom += shiftY; centre = new Vector2((left + right) / 2, (top + bottom) / 2); velocity = new Vector2(shiftX, shiftY); }