I want to create a similar game like Flower where the camera follows along a cloth like object in the wind.
I’ve watched many camera tutorials and all of them focus on needing a PlayerTransform to focus the camera on. What i’ve learned is that a cloth system actually alters the mesh itself and not the object. The transform stays in place while the cloth takes off in the wind. Is there any way to make the camera focus on the mesh or the vertices instead of the transform? The code I use right now is:
public class PlayerFollow : MonoBehaviour
{
public Transform PlayerTransform;
private Vector3 _cameraOffset;
[Range(0.01f, 1.0f)]
public float SmoothFactor = 0.5f;
// Start is called before the first frame update
void Start()
{
_cameraOffset = transform.position - PlayerTransform.position;
}
// Update is called once per frame
void LateUpdate()
{
Vector3 newPos = PlayerTransform.position + _cameraOffset;
transform.position = Vector3.Slerp(transform.position, newPos, SmoothFactor);
}
}
I don’t have a lot of experience with coding so I guess I should change the PlayerTransform.position?