Exemplo n.º 1
0
    private IEnumerator Player()
    {
        Recording recording = playerVCR.GetRecording();

        if (recording == null)
        {
            yield break;
        }

        Debug.Log(recording.ToString());
        curPlayer = (InputVCR)Instantiate(playbackCharacterPrefab, recordingStartPos, recordingStartRot);
        curPlayer.Play(Recording.ParseRecording(recording.ToString()));
        SwapTex();

        float playTime = recording.recordingLength;
        float curTime  = 0f;

        isPlaying = true;
        while (curTime < playTime)
        {
            if (isPlaying)
            {
                curTime += Time.deltaTime;
            }

            yield return(0);
        }

        // Play finished
        isPlaying = false;
        Destroy(curPlayer.gameObject);
        curPlayer = null;
        SwapTex();
    }
Exemplo n.º 2
0
    private IEnumerator Player()
    {
        Recording recording = playerVCR.GetRecording ();
        if ( recording == null )
            yield break;

        Debug.Log ( recording.ToString () );
        curPlayer = (InputVCR)Instantiate ( playbackCharacterPrefab, recordingStartPos, recordingStartRot );
        curPlayer.Play ( recording );
        SwapTex ();

        float playTime = recording.recordingLength;
        float curTime = 0f;

        isPlaying = true;
        while ( curTime < playTime )
        {
            if ( isPlaying )
                curTime += Time.deltaTime;

            yield return 0;
        }

        // Play finished
        isPlaying = false;
        Destroy ( curPlayer.gameObject );
        curPlayer = null;
        SwapTex ();
    }
Exemplo n.º 3
0
    void Awake()
    {
        vcr = GetComponent<InputVCR>();

        targPos = transform.position;
        targRot = transform.rotation;
        lastPos = transform.position;
        lastRot = transform.rotation;
    }
Exemplo n.º 4
0
    public float damping = 10f;         // how fast playback will catch up to recording. Higher = more accurate but less smooth

    void Awake()
    {
        vcr = GetComponent <InputVCR>();

        targPos = transform.position;
        targRot = transform.rotation;
        lastPos = transform.position;
        lastRot = transform.rotation;
    }
Exemplo n.º 5
0
    void Awake()
    {
        motor = GetComponent<CharacterMotorCS>();

        Transform root = transform;
        while ( root.parent != null )
            root = root.parent;
        vcr = root.GetComponent<InputVCR>();
        useVCR = vcr != null;
    }
Exemplo n.º 6
0
    void Awake()
    {
        Transform root = transform;

        while (root.parent != null)
        {
            root = root.parent;
        }
        vcr    = root.GetComponent <InputVCR>();
        useVCR = vcr != null;
    }
Exemplo n.º 7
0
    void Start()
    {
        // Make the rigid body not change rotation
        if (rigidbody)
            rigidbody.freezeRotation = true;

        Transform root = transform;
        while ( root.parent != null )
            root = root.parent;
        vcr = root.GetComponent<InputVCR>();
        useVCR = vcr != null;
    }
Exemplo n.º 8
0
    void Awake()
    {
        motor = GetComponent <CharacterMotorCS>();

        Transform root = transform;

        while (root.parent != null)
        {
            root = root.parent;
        }
        vcr    = root.GetComponent <InputVCR>();
        useVCR = vcr != null;
    }
Exemplo n.º 9
0
    void Start()
    {
        // Make the rigid body not change rotation
        if (rigidbody)
        {
            rigidbody.freezeRotation = true;
        }

        Transform root = transform;

        while (root.parent != null)
        {
            root = root.parent;
        }
        vcr    = root.GetComponent <InputVCR>();
        useVCR = vcr != null;
    }
Exemplo n.º 10
0
    void Update()
    {
        if (vcr.mode == InputVCRMode.Playback)
        {
            // will try to guess next target position between network frames.
            Vector3    posChange = transform.position - lastPos;
            Quaternion rotChange = Quaternion.FromToRotation(lastRot.eulerAngles, transform.rotation.eulerAngles);

            targPos += posChange;
            targRot *= rotChange;

            Debug.Log("targ" + targPos);
            Debug.Log("actual: " + transform.position);

            transform.position = Vector3.Lerp(transform.position, targPos, Time.deltaTime * damping);
            transform.rotation = Quaternion.Lerp(transform.rotation, targRot, Time.deltaTime * damping);

            // update target pos if location was recorded this frame
            string posString = vcr.GetProperty("position");
            if (!string.IsNullOrEmpty(posString))
            {
                targPos = InputVCR.ParseVector3(posString);
            }
            string rotString = vcr.GetProperty("rotation");
            if (!string.IsNullOrEmpty(rotString))
            {
                targRot = Quaternion.Euler(InputVCR.ParseVector3(rotString));
            }

            lastPos = transform.position;
            lastRot = transform.rotation;
        }
        else
        {
            lastPos = targPos = transform.position;
            lastRot = targRot = transform.rotation;
        }
    }