Beispiel #1
0
    private void UseVelocity(LaserPonterReciever lpr)
    {
        Time.timeScale = 0.5f;

        //Calculate velocity and apply it to the target
        Vector3 velocity = RATSCalculations.CalculateParabola(lpr.gameObject.transform.position,
                                                              objectAttachmentPoint.position);
        Vector3 dampVelocity = Vector3.Scale(velocity, velocityDampening);

        // Debug.Log("Velocity: " + velocity);
        // Debug.Log("Dampened Velocity: " + dampVelocity);
        lpr.rigidbody.velocity = dampVelocity;
    }
Beispiel #2
0
    private IEnumerator UseBezierCurve(LaserPonterReciever lpr)
    {
        float   step = 1;
        Vector3 peak = RATSCalculations.CalculateMidpoint(lpr.gameObject.transform, objectAttachmentPoint);

        peak += new Vector3(0, 1, 0);

        Vector3 start  = lpr.gameObject.transform.position;
        Vector3 target = objectAttachmentPoint.position;

        // Debug.LogWarning("Gravity off", this);
        lpr.rigidbody.useGravity  = false;
        lpr.rigidbody.isKinematic = true;
        lpr.moveToTarget          = true;
        lpr.interrupt             = false;
        nextStep = false;

        while (step <= bezierSteps && !interrupt)
        {
            // Debug.Log("Step: " + step + " || " + step / bezierSteps + " Start: " + start + " End: " + target +
            // " Current: " + lpr.gameObject.transform.position);

            nextStep = false;

            Vector3 newPos = RATSCalculations.CalculateQuadraticBezierCurves(start,
                                                                             peak, target, step / bezierSteps);
            lpr.target = newPos;
            step++;

            yield return(new WaitUntil(() => nextStep));
        }

        if (interrupt)
        {
            Debug.LogWarning("Interrupt", this);
        }
        else
        {
            // Debug.LogWarning("Gravity on", this);
            lpr.rigidbody.useGravity  = true;
            lpr.rigidbody.isKinematic = false;
        }

        // Debug.LogWarning("Moving finished", this);
        lpr.moveToTarget = false;
        isMoving         = false;
    }