Пример #1
0
    void Update()
    {
        if (!softVolume.Ready())
        {
            return;
        }
        softVolume.Fix();

        Partix.Body[] a = softVolume.GetContacts();

        Vector3 v0 = softVolume.GetPosition();

        foreach (Partix.Body b in a)
        {
            if (b as Partix.SoftVolume == null)
            {
                continue;
            }

            Vector3 v1   = b.GetPosition();
            Vector3 diff = v1 - v0;
            diff.y = 0;
            if (diff.sqrMagnitude == 0)
            {
                continue;
            }
            Vector3 d = diff.normalized;
            b.AddForce(d * 320.0f);
            softVolume.AddForce(-d * 15.0f);
            // b.AddForce(Vector3.up * 10.0f);
        }
    }
Пример #2
0
    public override void Subscribe(Breathe breathe)
    {
        Vector3 a   = (transform.position - breathe.origin).normalized;
        Vector3 b   = breathe.direction.normalized;
        float   dot = Vector3.Dot(a, b);

        if (dot < 0)
        {
            return;
        }

        float lenSq = a.sqrMagnitude;

        Debug.Log(lenSq);
        if (0.1f < lenSq && lenSq <= breathe.range * breathe.range)
        {
            entity.AddForce(b * dot * breathe.power / lenSq);
        }
    }