I want to achieve a camera that moves once every 0.1 seconds towards an object, but when the camera is close to the object, the camera’s orientation is not that object.
The top view is as follows,The blue arrow is the direction the camera is facing.the starting position camera position orientation is correct.
There may be some deviation in the middle position.da
After walking through the vertical position, camera don’t face the object at all
code show as below
private void PreProcess()
{
if (index < samplePointCoordinate.Count)
{
float S = VQ1.S;
float S_obj = VQ1.S_obj;
Debug.Log("S:" + S + "S_obj:" + S_obj + "count:" + samplePointCount + "position:" + samplePointCoordinate[index] +"index:"
+ index+ "TestSamplePointPrefab" + TestSamplePointPrefab.transform.position);
samplePointCount++;
if (S < S_Threshold || S_obj < S_obj_Threshold)
{
samplePointCoordinate.RemoveAt(index );
index--;
}
index++;
if(index < samplePointCoordinate.Count)
{
[B] TestSamplePointPrefab.transform.position = samplePointCoordinate[index];
TestSamplePointPrefab.transform.LookAt(middlePoint);[/B]
}
}
else
{
Destroy(TestSamplePointPrefab);
for(int i = 0;i < samplePointCoordinate.Count; i++)
{
Vector3 position = samplePointCoordinate[i];
GameObject samplePoint = Instantiate(samplePointPrefab, position, samplePointPrefab.transform.rotation, transform);
samplePoint.transform.forward = (middlePoint - position).normalized;
cameraRenders[position] = samplePoint;
}
IsPreProcessState = false;
}
}
I don’t know what the problem is, hope anyone can help


