Static generated mesh moves when camera is rotating
Hello,
I have the following scenario - I have generated a simple line using mesh renderer and mesh filter. The line is built from points on which I calculate the vertices and the triangle indices and then I build the mesh. So far so good. Now, I have made a game object which is receiving some points in the world space and is going from one point to another and so on. Each of the points will eventually cross my generated line. I have a camera attached to the game object to follow it.
Now, the problem comes when my game object is going over the mesh line - the camera is following it and the mesh seems to be somehow moving. The problem is starting to grow even if there are some points which are going from one end of the line to another and the camera, which is following, starts to see the mesh, the mesh starts to rotate somehow. It is like a drift, the mesh starts to drift to the direction in which the camera is facing.
What I want to achieve is the following, the mesh line not to move at all - I know this is a visual effect made by the camera because my mesh is generated in the Start event.
Could you please suggest me some camera property or camera modification magic which could help me resolve this?
And also, is there any way how to render some object and that object not to be affected by the camera movement.
Best regards
The code for player movement:
if (distanceTravelled > 20)
{
transform.position = positionPoint;
}
transform.position = Vector3.MoveTowards(transform.position, positionPoint , positionSpeed * distanceTravelled * Time.deltaTime);
Code for player rotation:
Vector3 dir = point - transform.position;
transform.rotation = Quaternion.LookRotation(dir * Time.deltaTime, Vector3.up);
Code for camera follow:
transform.position = target.TransformPoint(cameraPositionOffset);
transform.LookAt(target);
The target is the player
Your answer
Follow this Question
Related Questions
Character facing direction of movement - movement using camera transform? 1 Answer
When attaching my custom camera script camera shakes when player starts to move fast. 0 Answers
Spyro Like Camera Follow 0 Answers
Camera EdgeScrolling Question 0 Answers
Move camera to look around with mouse 0 Answers