Exemple #1
0
 void FixedUpdate()
 {
     if (Time.fixedTime - seconds >= 0.1)
     {
         if (!battery.Empty() && Input.GetAxis("P1B") > 0)
         {
             ShootBullet();
             battery.Shooting(true);
         }
         else
         {
             battery.Shooting(false);
         }
         seconds = Time.fixedTime;
     }
 }
Exemple #2
0
    // Update is called once per frame
    void FixedUpdate()
    {
        JointMotor motor = weapon.motor;

        if (!battery.Empty() && Input.GetAxis("P2B") > 0)
        {
            motor.targetVelocity = -1759;
            battery.WeaponOn(true);
        }
        else
        {
            motor.targetVelocity = 0;
            battery.WeaponOn(false);
        }

        weapon.motor = motor;
    }
    // Update is called once per frame
    void FixedUpdate()
    {
        float v = Input.GetAxis("P" + playerNumber + "Yaxis") * motorForce;
        float h = Input.GetAxis("P" + playerNumber + "Xaxis") * motorForce;

        if (Input.GetButtonDown("P" + playerNumber + "X"))
        {
            flip.Pressing(true);
            print("oi");
        }
        else
        {
            flip.Pressing(false);
        }
        if (flip.Full())
        {
            flip.Reset();
            ResetPos();
        }

        if (Vector3.Dot(transform.up, Vector3.down) > 0)
        {
        }
        else
        {
            resetting = false;
            seconds   = Time.fixedTime;
        }

        if (battery.Empty())
        {
            motorForce = 2700;
        }

        if (v <= motorForce && v > motorForce - 1000)
        {
            leftWheel.motorTorque       = -motorForce;
            leftWheelFront.motorTorque  = -motorForce;
            rightWheel.motorTorque      = -motorForce;
            rightWheelFront.motorTorque = -motorForce;

            leftWheel.brakeTorque       = 0;
            rightWheel.brakeTorque      = 0;
            leftWheelFront.brakeTorque  = 0;
            rightWheelFront.brakeTorque = 0;

            battery.Driving(true);
        }
        else if (v >= -motorForce && v < -motorForce + 1000)
        {
            leftWheel.motorTorque       = motorForce;
            leftWheelFront.motorTorque  = motorForce;
            rightWheel.motorTorque      = motorForce;
            rightWheelFront.motorTorque = motorForce;

            leftWheel.brakeTorque       = 0;
            rightWheel.brakeTorque      = 0;
            leftWheelFront.brakeTorque  = 0;
            rightWheelFront.brakeTorque = 0;

            battery.Driving(true);
        }
        else if (h >= -motorForce && h < -motorForce + 1000)
        {
            leftWheel.motorTorque       = motorForce * spinFactor;
            leftWheelFront.motorTorque  = motorForce * spinFactor;
            rightWheel.motorTorque      = -motorForce * spinFactor;
            rightWheelFront.motorTorque = -motorForce * spinFactor;

            leftWheel.brakeTorque       = 0;
            rightWheel.brakeTorque      = 0;
            leftWheelFront.brakeTorque  = 0;
            rightWheelFront.brakeTorque = 0;

            battery.Driving(true);
        }
        else if (h <= motorForce && h > motorForce - 1000)
        {
            leftWheel.motorTorque       = -motorForce * spinFactor;
            leftWheelFront.motorTorque  = -motorForce * spinFactor;
            rightWheel.motorTorque      = motorForce * spinFactor;
            rightWheelFront.motorTorque = motorForce * spinFactor;

            leftWheel.brakeTorque       = 0;
            rightWheel.brakeTorque      = 0;
            leftWheelFront.brakeTorque  = 0;
            rightWheelFront.brakeTorque = 0;

            battery.Driving(true);
        }
        else
        {
            leftWheel.motorTorque       = 0;
            leftWheelFront.motorTorque  = 0;
            rightWheel.motorTorque      = 0;
            rightWheelFront.motorTorque = 0;

            leftWheel.brakeTorque       = brakeForce;
            rightWheel.brakeTorque      = brakeForce;
            leftWheelFront.brakeTorque  = brakeForce;
            rightWheelFront.brakeTorque = brakeForce;

            battery.Driving(false);
        }

        if (Input.GetAxis("P" + playerNumber + "A") > 0)
        {
            leftWheel.brakeTorque       = brakeForce;
            rightWheel.brakeTorque      = brakeForce;
            leftWheelFront.brakeTorque  = brakeForce;
            rightWheelFront.brakeTorque = brakeForce;

            battery.Driving(false);
        }
        else
        {
            leftWheel.brakeTorque       = 0;
            rightWheel.brakeTorque      = 0;
            leftWheelFront.brakeTorque  = 0;
            rightWheelFront.brakeTorque = 0;
        }
    }