Dynamic recording of objects position seems fine, playback is too fast.

Im new to unity and im wanting to record the movement of an object so that it can be played back.
I have the x,y,z positions recorded but when it comes to replaying the movement it is happening so fast that it gives the impression that the gameobject jumps to the last recorded position instead of actually moving through the recorded positions.

Im stuck as to how i can replay the movement at the same speed as it happened.

my code for this is:

using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;

public class recordv1 : MonoBehaviour {

	List<float> nums = new List<float>();
	bool isRec = false;
	bool doPlay = false;
	float tempX;
	float tempY;
	float tempZ;
	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
	
		if( Input.GetKeyDown (KeyCode.R)) {
			if( isRec == false){isRec = true;}
			else{
				if( isRec == true){isRec = false;}
				
			}
		}
		
		if( isRec == true){
			tempX = transform.position.x;
			tempY = transform.position.y;
			tempZ = transform.position.z;
			nums.Add(tempX);
			nums.Add(tempY);
			nums.Add(tempZ);
		}
		
		if( Input.GetKeyDown (KeyCode.P)) {
			if( doPlay == false){doPlay = true;}
			else{}
			
		if(doPlay == true){
			
			for (int i = 0; i < nums.Count; i+=3){
					transform.position = new Vector3(nums*,nums[i+1],nums[i+2]);*
  •  		}*
    
  •  		doPlay = false;*
    
  •  	}*
    
  •  }*
    
  • }*
    }

Yeah, you should only update the position once a frame. Not all of them in one frame.
I can see two obvious ways you could do it. One is to declare the variable “i” that you use to become a member variable so it remembers where it is between calls. You’d have to make special check to see if you reached the end before you set doPlay to false.

The other is to use a coroutine that processes them each frame. You can wait for the next frame with “yield return null;”.

IEnumerator Playback ()
{
	for (int i = 0; i < nums.Count; i+=3) {
		transform.position = new Vector3 (nums *, nums [i + 1], nums [i + 2]);*
  •   	yield return null;*
    
  •   }*
    
  • }*
    To start it, you should call StartCoroutine(“Playback”);

this plug-in helps record movement of any 3d object, including avatars or complex object with multiple children… all you do is check one flag. Easy to import and use. check out the demo: GameRec unity3d asset tutorial Demo - YouTube

link in asset store; Unity Asset Store - The Best Assets for Game Making