- Home /
Lerping saved position in FixedUpdate causes inconsistent in speed with the reply !
I have a racing game where im saving ghost and sending the said saved ghosts to friends, the problem is when i save the position and rotation in fixed update and play back the saved position in the fixed update the playback is moving to fast than the saved ghost (i.e the replay of the position and rotation is not int he same time span when its saved) i have attached my code down
 void FixedUpdate()
 {
// for playing back the saved positions and rotation
     if(StartGhost)
     {
         check++;
         if (!gameObject.activeSelf)
         {
             gameObject.transform.position = ReadPosition[0];
             gameObject.transform.rotation = ReadRotation[0];
             gameObject.SetActive(true);
         }
         if (check != ReadPosition.Count)
         {
// Tried different lerping and things all same results
             // gameObject.transform.position = Vector3.Slerp(gameObject.transform.position, ReadPosition[check], Time.deltaTime / 0.001f);
             // gameObject.transform.rotation = Quaternion.SlerpUnclamped(gameObject.transform.rotation, ReadRotation[check], Time.deltaTime / 0.02f);
             // PlayerCarInstance.transform.position = Vector3.SmoothDamp(PlayerCarInstance.transform.position, ReadPosition[check], ref testref, 0.2f);
               gameObject.transform.position = Vector3.Lerp(gameObject.transform.position, ReadPosition[check], Time.smoothDeltaTime/0.2f );
            // gameObject.transform.position = ReadPosition[check];
             gameObject.transform.rotation = Quaternion.SlerpUnclamped(gameObject.transform.rotation, ReadRotation[check], Time.fixedDeltaTime / 0.02f);
             //PlayerCarInstance.transform.rotation = ReadRotation[check];
         }
         else
         {
             StartGhost = false;
         }
         
     }
// for saving the ghost
     if(SaveGhost)
     {
         Position.Add(this.transform.position);
         Rotation.Add(this.transform.rotation);
         //Debug.Log (RealPlayer.transform.position.ToString());
         Count++;
         if(carcontroller.Levelended && carcontroller.isIA != false)
         {
             timer -= Time.deltaTime;
             if(timer < 0)
             {
                 Ghostmanager.Position = Position;
                 Ghostmanager.Rotation = Rotation;
                 Ghostmanager.Count = Count;
                 SaveGhost = false;
             }
         }
     }
 }
if any one can point out what im doing wrong it will be helpful ! thanks in advance
If i change the Updates to late or normal it interferes with camera update and causes massive jitters
Your answer
 
 
             Follow this Question
Related Questions
ghost replay system as for a racing game ? 2 Answers
How to play animation just once whenver i shoot a bullet( bullet's flash animation) ? 0 Answers
2D Platformer Ghost Replay 2 Answers
Sharing a project with team members not using PRO License 1 Answer
How can you use Unity to make an iOS app that's not a game? 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                