I’m really quite stuck on this, so anything is welcome!
My issue’s the following:
I’ve got a TileMap generator, and I want my camera to clamp to this TileMap (not with box collide stuff, pure coding!) Now I’ve got the feeling I almost tried everything, but I’m obviously missing something.
When I try to clamp my Camera the following way (this is along the X-Axis):
MoveTo.x = Mathf.Clamp(Target.transform.position.x,
(CameraWidth / 2),
(Global.MapWidth * Global.TileSize) - camera.orthographicSize * camera.aspect);
It gives a value, which is of course well calculated, but this does not fit the TileMap. Everything has been debugged and all the values are right:
Global.TileSize = 1.6
camera.orthographicSize = 4
CameraWidth = 2 * camera.orthographicSize * camera.aspect
Anything I seem to do returns this: a little bit too much spacing, a little bit too loosened. Now I’m really quite eager to know how this has to be done! (and I mean ANY screen resolution, no hard coding).
Anyone knows what I’m doing wrong and even better how it should be done?
Thanks in advance!