Exemplo n.º 1
0
    public void ProjectileTrajectory()
    {
        barrelPos      = transform.position + (transform.up * barrelLength);
        fireVelocity   = (fireSpeed * transform.up) + new Vector3(transform.parent.GetComponent <Ship>().velocity.x, transform.parent.GetComponent <Ship>().velocity.y);
        turretLineDraw = GetComponent <TrajectoryPredict>();

        //float a = Vector3.Angle(transform.up, transform.parent.GetComponent<Rigidbody2D>().velocity) / 180;
        //int lineRes = Mathf.CeilToInt(Mathf.Lerp(lineResMax, 1, a));

        int lineRes = 10;

        turretLineDraw.SimulatePath(barrelPos, fireVelocity, lineDistanceMax, lineRes);
    }
Exemplo n.º 2
0
    protected override void FixedUpdate()
    {
        base.FixedUpdate();

        //Player Acceleration Input
        inputAxis      = AccelAxis();
        direction      = rb.velocity.normalized;
        accelMagnitude = accelRate * inputAxis;
        accelVector    = accelMagnitude * direction;
        rb.AddForce(accelVector * rb.mass);

        trajectory.SimulatePath(transform.position, rb.velocity, 200, 2);

        //Animation (consider separating out into another class)
        if (inputAxis > 0)
        {
            if (!thrusterBaseAudio.isPlaying)
            {
                thrusterBaseAudio.Play();
            }
            justAccelerated = true;

            for (int i = 0; i < thrustersBackLeft.Length; i++)
            {
                thrustersBackLeft[i].SetBool("accelerating", true);
                thrustersBackRight[i].SetBool("accelerating", true);
            }
            for (int i = 0; i < thrustersFrontLeft.Length; i++)
            {
                thrustersFrontLeft[i].SetBool("accelerating", false);
                thrustersFrontRight[i].SetBool("accelerating", false);
            }
        }
        else if (inputAxis < 0)
        {
            if (!thrusterBaseAudio.isPlaying)
            {
                thrusterBaseAudio.Play();
            }
            justAccelerated = true;

            for (int i = 0; i < thrustersBackLeft.Length; i++)
            {
                thrustersBackLeft[i].SetBool("accelerating", false);
                thrustersBackRight[i].SetBool("accelerating", false);
            }
            for (int i = 0; i < thrustersFrontLeft.Length; i++)
            {
                thrustersFrontLeft[i].SetBool("accelerating", true);
                thrustersFrontRight[i].SetBool("accelerating", true);
            }
        }
        else
        {
            if (justAccelerated == true)
            {
                thrusterBase.AddComponent <AudioFade>().fullVolume = 0.5f;
            }
            justAccelerated = false;

            for (int i = 0; i < thrustersBackLeft.Length; i++)
            {
                thrustersBackLeft[i].SetBool("accelerating", false);
                thrustersBackRight[i].SetBool("accelerating", false);
            }
            for (int i = 0; i < thrustersFrontLeft.Length; i++)
            {
                thrustersFrontLeft[i].SetBool("accelerating", false);
                thrustersFrontRight[i].SetBool("accelerating", false);
            }
        }
    }