- Home /
Making the camera follow vertices
Hello everyone,
I'm currently working on a project with cloth that blows through the wind. I want to attach the camera to the cloth so that it follows it's path. The problem is that Cloth simulations happen to deform the vertices instead of "move" the object, therefore the gameObject would be still from the Transform point of view. I've read somehwere that the way to move the camera along with the cloth is to track the vertex instead of the gameObject. Does anyone know the correct script for this? My current script (the one below is still following the gameObject. What do I need to change in this code for it to follow the vertices instead?
void Start()
{
_cameraOffset = transform.position - PlayerTransform.position;
}
void LateUpdate()
{
Vector3 newPos = PlayerTransform.position + _cameraOffset;
transform.position = Vector3.Slerp(transform.position, newPos, SmoothFactor);
}
Your answer
Follow this Question
Related Questions
vertices in current camera view 1 Answer
Vertex Shader problem with _WorldSpaceCameraPos 1 Answer
How to return mesh of interactive cloth? 0 Answers
Interactive Cloth - Mobile? 1 Answer
Vertex count 10 times higher in Unity 5 Answers