Example #1
0
        // Update function, called once per frame.  Records the current inputs, and
        // occasionally physics + position data, to compensate for floating point drift.
        public void Update(PlayerController playerBall, int timestamp)
        {
            InputControllers.BasePlayerController playerController = playerBall.inputController;

            if (timestamp % positionRecordFrequencyInHz == 0)
            {
                Rigidbody         rigidbody         = playerBall.gameObject.GetComponent <Rigidbody>();
                PositionDataEntry positionDataEntry = new PositionDataEntry(
                    timestamp,
                    rigidbody.position,
                    rigidbody.rotation,
                    rigidbody.velocity,
                    rigidbody.angularVelocity);

                positionData.Add(positionDataEntry);
            }
            Vector2 playerInputVector = playerBall.inputController.GetInputVector();

            if (previousPlayerInputVector != playerInputVector)
            {
                InputDataEntry inputDataEntry = new InputDataEntry(timestamp, playerInputVector);

                inputData.Add(inputDataEntry);
                previousPlayerInputVector = playerInputVector;
            }
        }
Example #2
0
        // Update function, called once per frame.  Records the current inputs, and
        // occasionally physics + position data, to compensate for floating point drift.
        public void Update(PlayerController playerBall, int timestamp)
        {
            // Only record before maximum frames of position data has been recorded.
            if (positionData.Count < maxRecords && inputData.Count < maxRecords)
            {
                InputControllers.BasePlayerController playerController = playerBall.inputController;
                if (timestamp % positionRecordInterval == 0)
                {
                    Rigidbody         rigidbody         = playerBall.gameObject.GetComponent <Rigidbody>();
                    PositionDataEntry positionDataEntry = new PositionDataEntry(
                        timestamp,
                        rigidbody.position,
                        rigidbody.rotation,
                        rigidbody.velocity,
                        rigidbody.angularVelocity);

                    positionData.Add(positionDataEntry);
                }
                Vector2 playerInputVector = playerBall.inputController.GetInputVector();
                if (previousPlayerInputVector != playerInputVector)
                {
                    InputDataEntry inputDataEntry = new InputDataEntry(timestamp, playerInputVector);

                    inputData.Add(inputDataEntry);
                    previousPlayerInputVector = playerInputVector;
                }
            }
        }