I would like to ask you how can I make smooth object movements in Unity ?

In my scene I have a sun that changes its position based on values detected in real-time from Arduino, actually I’m using this function but it doesn’t work, because it’s change like a flash and not smoothly.

private void ReadValue(int[][] packageOfData, int chnIndex)
{
for (int i = 0; i < packageOfData.Length; i++)
{
if (packageOfData[i][chnIndex] < 1000 && packageOfData[i][chnIndex] > 800)
{
if (DirectionalLight != null)
{
DirectionalLight.transform.rotation = Quaternion.Slerp(point0.rotation, pointA.rotation, timeCount);
timeCount = timeCount + Time.deltaTime;
}
}
}
}

I don’t know enough about your project to answer this question but for slerp, your third parameter needs to a value between 0 and 1, so instead of just timeCount, you probably want timeCount divided by the total time (in seconds) it should take to get from point0.rotation to pointA.rotation.

The third parameter in any of Unity’s Lerping functions needs to be between 0 and 1. Anything greater than 1 will just be substituted for 1. Think about the third parameter of Slerp like a percentage. What percent between Point0 and PointA do you want your transform rotation to be at any given moment? if you pass in 0 as the third parameter then you’ll get Point0.rotation. If you pass 1 as the third parameter then you’ll get PointA.rotation. If you pass in 0.5 you’ll get half-way between Point0.rotation and PointA.rotation.

Assuming Point0 and PointA are fixed, then timeCount divided by the total time (as I mentioned previously) will give you a number between 0 and 1 that is proportional to the amount of the duration that has already passed. That’s just a guess based on common use-cases. I have no idea what point0.rotation and pointA.rotation represent.