I simply want the camera to stay in the middle between two game objects, (its like a co-op game), everything ive tried hasnt worked. can anyone help please? its 2d btw!
Group the 2 gameobjects in an empty gameobject put the camera inside of the group and move it exactly in place where you want it to be. Now when the group moves the camera will move too and will stay wherever you put it.
Get the position between the two GameObjects: Code (CSharp): Vector3 posBetween = Vector3.Lerp(obj1.transform.position, obj2.transform.position, 0.5f); Then you can apply an offset to this position (or the camera will be really between the two in the ground). Code (CSharp): posBetween += cameraOffset; If you want to apply a rough delay in a sec you can do this: Code (CSharp): float smoothSpeed = 3; // tweak this cam.transform.position = Vector3.Lerp(cam.transform.position, posBetween, Time.deltaTime * smoothSpeed); It's doesn't change much for 2D.
Well you can also take the direction from obj1 to obj2 then takes the distance and do obj1.position + dir * dist * 0.5f but that's basically what lerp do.
That's how I was going to suggest to do it, I know how lerp works but haven't ever thought about using a lerp to do things like this so thumbs up.