unit – How to align the FixedUpdate variable change with the user's entries

I create a little endless runner where the player has to slide up and down on the screen to move a fish. Imagine Subway Surfers where you travel smoothly rather than jumping from one foot to the left or right. Whatever it is, I try to rotate the fish in the approximate direction of the player's finger and bring it back gradually as the player loosens the screen. The program worked almost smoothly – aside from the fact that the fish was constantly returning to its default position, so it looked really glitchy.

The way this script works is to integrate two variables Vector2 – the current and previous positions of the fish. It subtracts them then to obtain a vector2 indicating the change of position since the last image. I then feed him in Mathf.Atan to get the direction of this motion. Finally, I rotate the fish of this new quantity – minus its current rotation – to move it in the right direction. I will show the code below. After studying why this resulted in constant rotation of the fish at 0 degrees for several images, I learned that Unity thought that the change of position allowed to zero all other images. All my code works on FixedUpdate and I do not use Update anywhere, so I do not know why it changes so irregularly. If the touch input of the user is measured during the update, this could be the source of the problem, but it would be nice if I could find a solution. I am just a little confused, and would love if someone could clear that up for me as soon as possible.

Now, here is my code for the "RotateByTouch" class:

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

Public class RotateByTouch: MonoBehaviour
{
public TrackObjectMotion trackObjectMotion;
public GameObject thisObject;

public float rotationValue;

void FixedUpdate ()
{

rotationValue = Mathf.Atan (trackObjectMotion.DeltaY / trackObjectMotion.DeltaX) * Mathf.Rad2Deg;

thisObject.transform.Rotate (Vector3.forward, rotationValue - thisObject.transform.rotation.eulerAngles.z);

}


}

And here is my code for the class "TrackObjectMotion":

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

public class TrackObjectMotion: MonoBehaviour
{

public Vector3 CurrentPosition;
public Vector3 PreviousPosition;

floating public DeltaX;
floating DeltaY public;

// The update is called once per image
void FixedUpdate ()
{
PreviousPosition = CurrentPosition;
CurrentPosition = this.gameObject.transform.position;

DeltaX = CurrentPosition.x - PreviousPosition.x;
DeltaY = CurrentPosition.y - PreviousPosition.y;
}
}

Thanks in advance!