コード例 #1
0
    public override void ModifyMoveForce(KobotoMoveForce moveForce, InputData input, KobotoSensor sensors, KobotoParameters parameters)
    {
        if (!open)
        {
            return;
        }
        float speedError  = terminalVelocity - sensors.velocity.y;
        float upDragForce = dragControl.Update(speedError, Time.fixedDeltaTime);

        //  float upDragForce = 15f;
        //  Debug.Log("Up force " + upDragForce);

        moveForce.tiltAngle    = 25f * input.move;
        moveForce.tiltStrength = 0.2f;
        moveForce.airDrag      = 1f;


        moveForce.airMove     += Vector3.up * upDragForce + sensors.forwardVector * input.move * 120f;
        moveForce.airMove     += sensors.windSpeed;
        moveForce.airForcesSet = true;
    }
コード例 #2
0
    public override void ModifyMoveForce(KobotoMoveForce moveForce, InputData input, KobotoSensor sensors, KobotoParameters parameters)
    {
        bool wasOverGround      = overGround;
        bool overGroundLocal    = sensors.localAboveGround && sensors.localGroundDist < maxHeight;
        bool overGroundVertical = sensors.aboveGround && sensors.heightAboveGround < maxHeight;

        overGround = overGroundLocal || overGroundVertical;

        if (overGround)
        {
            Vector3 point;
            if (overGround && overGroundLocal)
            {
                point = (sensors.aboveGroundPoint + sensors.localAboveGroundPoint) * 0.5f;
            }
            else
            {
                point = overGroundLocal ? sensors.localAboveGroundPoint : sensors.aboveGroundPoint;
            }
            if (!wasOverGround)
            {
                groundPoint = point;
            }
            else
            {
                groundPoint = Vector3.Lerp(groundPoint, point, 4f * Time.fixedDeltaTime);
            }

            groundVector = groundPoint - sensors.positionTrail[0];
            float height = groundVector.magnitude;

            dustVFX.transform.position = groundPoint;
            dustVFX.SetActive(true);

            float heightError = targetHeight - height;


            if (resetMotor)
            {
                motorControl.Reset(heightError);
                resetMotor = false;
            }

            motorForce = motorControl.Update(heightError, Time.fixedDeltaTime);

            float propSpeed = Mathf.Clamp01(motorForce / 100f);
            bladeSpeed = Mathf.Lerp(visualBladeSpeedMin, visualBladeSpeedMax, propSpeed);


            moveForce.tiltAngle    = 45f * input.move;
            moveForce.tiltStrength = 0.4f;
        }
        else
        {
            motorForce *= 1f - 0.2f * visualBladeSpeedSlowdown * Time.fixedDeltaTime;
            bladeSpeed *= 1f - visualBladeSpeedSlowdown * Time.fixedDeltaTime;
            dustVFX.SetActive(false);
        }

        moveForce.airMove = motorForce * strength * sensors.upVector;

        float glide = Mathf.Abs(Vector3.Dot(sensors.velocity, sensors.forwardVector));

        glide = Mathf.Clamp(glide, 0, 6f);

        Vector3 liftForce = glide * lift * sensors.upVector;

        moveForce.airMove += liftForce;

        moveForce.airForcesSet = true;

        bladeTransform.Rotate(Vector3.up * bladeSpeed, Space.Self);
    }