Esempio n. 1
0
    private void DeactivateMuscle()
    {
        isActive = false;
        //When deactivating, use lowest possible muscle force of 0.01f and do not multiply with strength
        muscle = new Muscle2(0.01f);
        double force = muscle.step(0.01f, Time.fixedDeltaTime);

        Vector3 forceOnRb2 = (a1.transform.position - a2.transform.position) * (float)force;
        Vector3 forceOnRb1 = (a2.transform.position - a1.transform.position) * (float)force;

        rb2.AddForceAtPosition(forceOnRb2, a2.transform.position);
        rb1.AddForceAtPosition(forceOnRb1, a1.transform.position);
    }
Esempio n. 2
0
    private void ActivateMuscle()
    {
        isActive = true;
        //Muscle force cannot be lower than 0.01f
        if (activationValue < 0.01f)
        {
            activationValue = 0.01f;
        }
        muscle = new Muscle2(activationValue);
        double force = muscle.step(activationValue, Time.fixedDeltaTime);

        Vector3 forceOnRb2 = (a1.transform.position - a2.transform.position) * (float)force * strength;
        Vector3 forceOnRb1 = (a2.transform.position - a1.transform.position) * (float)force * strength;

        rb2.AddForceAtPosition(forceOnRb2, a2.transform.position);
        rb1.AddForceAtPosition(forceOnRb1, a1.transform.position);
    }