private void Rewind() { if (recordingArray.Count > 0 && pc.stats.currentEnegy > 0) { isRecording = false; pc.ChangeMaterial(pc.blue); pc.audioSrc.PlayOneShot(pc.rewindSFX); PlayerController.PlayerRecording pr2 = (PlayerController.PlayerRecording)recordingArray[recordingArray.Count - 1]; pc.transform.position = pr2.pos; pc.transform.rotation = pr2.rot; pc.rb.velocity = pr2.velo; recordingArray.RemoveAt(recordingArray.Count - 1); } else { AbilityRelease(); } }
private void PlayerRecorder(float timeToTrack) { counter += Time.deltaTime; if (isRecording) { rewindCooldown -= Time.deltaTime; PlayerController.PlayerRecording pr = new PlayerController.PlayerRecording(pc.transform.position, pc.rb.velocity, pc.transform.rotation); recordingArray.Add(pr); } if (counter <= timeToTrack) { numofelements = recordingArray.Count; } if (recordingArray.Count > numofelements) { recordingArray.RemoveRange(0, recordingArray.Count - numofelements); } }