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;*
-
}*
-
}*
-
}*
}