Creature looks for food. Creature grows when food is successfully collected. Problem is Cinemachine stays in place, so if the creature grows too big, the camera doesn’t back up to accommodate size.
So, I figured accessing the tracked object offset or FOV for Cinemachine to adjust the distance from the creature when it grows is what’s best. I’m just struggling to wrap my head around the scripting.
I haven’t worked with Cinemachine a lot, so this is 100% just me being dumb. It’s been a fun few hours in struggle city but I’d like to leave now lol. I’ve always struggled with the documentation. Is someone able to break it down for me please.
using Cinemachine;
public class playerscript : MonoBehaviour
{
public GameObject creature;
public CinemachineVirtualCamera virtualCam;
// Start is called before the first frame update
void Start()
{
camOffset = virtualCam.GetCinemachineComponent<CinemachineComposer>().m_TrackedObjectOffset;
}
private void OnTriggerEnter(Collider collision)
{
if(collision.gameObject.tag == "Food")
{
Destroy(collision.gameObject);
Growth();
}
}
private void Growth()
{
creature.transform.localScale += new Vector3 (0.03f, 0f, 0.03f);
// push back/pull forward camera to accommodate new size
}
}