Exemple #1
0
    public void UpdateObservations(float timeDelta)
    {
        MocapCOMVelocity               = _mocapBodyStats.CenterOfMassVelocity;
        RagDollCOMVelocity             = _ragDollBodyStats.CenterOfMassVelocity;
        InputDesiredHorizontalVelocity = new Vector2(
            _ragDollBodyStats.DesiredCenterOfMassVelocity.x,
            _ragDollBodyStats.DesiredCenterOfMassVelocity.z);
        InputJump     = _inputController.Jump;
        InputBackflip = _inputController.Backflip;
        HorizontalVelocityDifference = new Vector2(
            _ragDollBodyStats.CenterOfMassVelocityDifference.x,
            _ragDollBodyStats.CenterOfMassVelocityDifference.z);

        MocapBodyStats = BodyPartsToTrack
                         .Select(x => _mocapBodyStats.Stats.First(y => y.Name == x))
                         .ToList();
        RagDollBodyStats = BodyPartsToTrack
                           .Select(x => _ragDollBodyStats.Stats.First(y => y.Name == x))
                           .ToList();
        // BodyPartStats =
        foreach (var differenceStats in BodyPartDifferenceStats)
        {
            var mocapStats   = _mocapBodyStats.Stats.First(x => x.Name == differenceStats.Name);
            var ragDollStats = _ragDollBodyStats.Stats.First(x => x.Name == differenceStats.Name);

            differenceStats.Position        = mocapStats.Position - ragDollStats.Position;
            differenceStats.Velocity        = mocapStats.Velocity - ragDollStats.Velocity;
            differenceStats.AngualrVelocity = mocapStats.AngualrVelocity - ragDollStats.AngualrVelocity;
            differenceStats.Rotation        = DReConObservationStats.GetAngularVelocity(mocapStats.Rotation, ragDollStats.Rotation, timeDelta);
        }
    }
Exemple #2
0
    void FixedUpdate()
    {
        float timeDelta = Time.fixedDeltaTime;

        foreach (var rb in _rigidbodies)
        {
            Stat stat = Stats.First(x => x.Name == rb.name);
            if (!stat.LastIsSet)
            {
                stat.LastPosition = rb.transform.position;
                stat.LastRotation = rb.transform.rotation;
            }
            stat.Position        = rb.transform.position;
            stat.Rotation        = rb.transform.rotation;
            stat.Velocity        = rb.transform.position - stat.LastPosition;
            stat.Velocity       /= timeDelta;
            stat.AngualrVelocity = DReConObservationStats.GetAngularVelocity(stat.LastRotation, rb.transform.rotation, timeDelta);
            stat.LastPosition    = rb.transform.position;
            stat.LastRotation    = rb.transform.rotation;
            stat.LastIsSet       = true;
        }
    }