I am trying to make the camera follow a cloth.
- I added a empty game object and then upon it, I added the interactive cloth and cloth renderer.
- Then I added a mesh through the interactive cloth inspecter pane.
- Now I added a script on the camera to follow the cloth when it moves by transformation of the game object.
- The cloth by the way, moves upon gravity and falls free.
Now when I look closing, the game object stays where it is supposed to be and the cloth does nt have any object with it.
Kindly let me know if I am wrong at any place and if not, what is the best alternative way to implement it.
Cloth simulation happens to deform the vertices instead of “move” the object, therefore the gameObject would be still from the Transform point of view, and child-parent relationship is not able to help in this case.
The way to move the camera along with the cloth is to track the vertex, Unity provide a function to retrieve the vertex position. You can refer to
only one vertex is enough, you could simply track the first vertex in the mesh or any ID you want in a FixUpdate or Update and adjust the camera transform according to that vertex position.
attach the cloth to the empty game object first if you haven’t done so.