Exemplo n.º 1
0
    public void SetNewTargetPosition(Vector3 pos)
    {
        walker.enabled = true;
        spline.endPoints[spline.Count - 1].position = walker.transform.position;
        BezierPoint p = spline.InsertNewPointAtWorldPosition(spline.Count, pos);

        p.precedingControlPointPosition *= 1.5f;
        Quaternion lookRot    = Quaternion.LookRotation(p.position - walker.transform.position, Vector3.forward);
        Vector3    conversion = new Vector3(0, lookRot.eulerAngles.y - 90, 0);

        p.rotation = Quaternion.Euler(conversion);

        spline.RemovePointAt(0);
        if (spline.Count > 2)
        {
            spline.RemovePointAt(0);
        }

        if (Vector3.Distance(walker.transform.position, p.position) > minDistanceForExtraSplinePoint)
        {
            p = spline.InsertNewPointAt(1);
            float splineLength = spline.Length * middleSplineLengthModifierMax;
            p.precedingControlPointLocalPosition = new Vector3(splineLength, p.precedingControlPointLocalPosition.y, p.precedingControlPointLocalPosition.z);
            lookRot = Quaternion.LookRotation(p.position - walker.transform.position, Vector3.forward);
            float angleModifier = 0;
            if (PetMinigame.Instance.lastEmotionCollected == Emotion.Happy)
            {
                angleModifier = middleSplineAngleEmotionHappyModifier;
            }
            conversion = new Vector3(0, (lookRot.eulerAngles.y + 90) + angleModifier, 0);
            p.rotation = Quaternion.Euler(conversion);
        }
        walker.ResetProgress();
    }
Exemplo n.º 2
0
    public void SetNewTargetPosition(Vector3 pos)
    {
        walker.enabled = true;
        spline.endPoints[spline.Count - 1].position = walker.transform.position;
        BezierPoint p = spline.InsertNewPointAtWorldPosition(spline.Count, pos);

        p.precedingControlPointPosition *= 1.5f;

        Quaternion lookRot    = Quaternion.LookRotation(p.position - walker.transform.position, Vector3.forward);
        Vector3    conversion = new Vector3(0, lookRot.eulerAngles.y - 90, 0);

        p.rotation = Quaternion.Euler(conversion);

        spline.RemovePointAt(0);
        if (spline.Count > 2)
        {
            spline.RemovePointAt(0);
        }

        walker.ResetProgress();
    }