Exemple #1
0
        /// <summary>
        /// Interprets the output and calls the respective function on the muscle.
        /// </summary>
        protected virtual void ApplyOutputToMuscle(float output, Muscle muscle)
        {
            // maps the output of the sigmoid function from [0, 1] to a range of [-1, 1]
            float percent = 2 * output - 1f;

            if (percent < 0)
            {
                muscle.muscleAction = Muscle.MuscleAction.CONTRACT;
            }
            else
            {
                muscle.muscleAction = Muscle.MuscleAction.EXPAND;
            }

            muscle.SetContractionForce(Math.Abs(percent));
        }
Exemple #2
0
    /** Interprets the output and calls the respective function on the muscle. */
    protected virtual void ApplyOutputToMuscle(float output, Muscle muscle)
    {
        //print(output);
        // shift the output of the sigmoid function to receive a value between -0.5 and 0.5
        // multiply by two to get a value between -1 and 1
        float percent = 2 * output - 1f;

        if (percent < 0)
        {
            muscle.muscleAction = Muscle.MuscleAction.CONTRACT;
        }
        else
        {
            muscle.muscleAction = Muscle.MuscleAction.EXPAND;
        }

        muscle.SetContractionForce(Math.Abs(percent));
    }