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(); }
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 (); }
void Awake() { vcr = GetComponent<InputVCR>(); targPos = transform.position; targRot = transform.rotation; lastPos = transform.position; lastRot = transform.rotation; }
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; }
void Awake() { motor = GetComponent<CharacterMotorCS>(); Transform root = transform; while ( root.parent != null ) root = root.parent; vcr = root.GetComponent<InputVCR>(); useVCR = vcr != null; }
void Awake() { Transform root = transform; while (root.parent != null) { root = root.parent; } vcr = root.GetComponent <InputVCR>(); useVCR = vcr != null; }
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; }
void Awake() { motor = GetComponent <CharacterMotorCS>(); Transform root = transform; while (root.parent != null) { root = root.parent; } vcr = root.GetComponent <InputVCR>(); useVCR = vcr != null; }
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; }
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; } }