if (mouseScroll != 0 isTooClose == false)
{
if (dist < 4.0f)
{
isTooClose = true;
return;
}
myCam.Translate(Vector3.forward * 350 * Time.deltaTime * Input.GetAxis("Mouse ScrollWheel"));
}
if (mouseScroll != 0 isTooClose == true)
{
float temp = Input.GetAxis("Mouse ScrollWheel");
if (temp != 0)
{
myCam.Translate(Vector3.forward * 350 * Time.deltaTime * Input.GetAxis("Mouse ScrollWheel"));
isTooClose = false;
}
}
dist = Vector3.Distance(myCam.position, playerObj.position);
This code here checks if the cam is too close to the player object through the Distance function. Anyways, how do I tell which side of the player the camera is on? If it’s on one side, I need the z axis to be incremented, otherwise I need it decremented.