make object cover the screen exactly?

hi there,

1st: Situation:
I want to switch the current visible screen to a battlescreen. Like in most rpgs. the battlefield is in the same scene as the map, and is only active via a boolean.

2nd: Problem:
The switching right now is happening from one frame to another.
But i want to have some nice effects as transition.

3rd: Idea:
My idea right now is, to create a plane object in C4D. This can have various animations like: breaking in shards, morph to a ball…etc
this plane should cover the camera view exactly.
As material, it’ll have a disolve+bump+transparent material, with an empty texture. And the object will be a child of the camera, to
make it follow in relation to it.
The object will be inactive.
When starting a battle, the game stopps and a screenshot is taken. this will be the texture of the transition object. Now the object will be set active, and starts his animation OR disolve effect of the shader.
meanwhile, the background scene has switched to his new position (to the battlefield).

4th: Question:
my question now: How can i make the objekt to cover the camera view exactly, doesn’t matter wich resolution-aspekt is used?
cause when i set the object correct on 1920*1080, it will be to big for lower resolutions (same the other way, but smaller).

i hope someone knows an answer to this :slight_smile:

Has anyone an idea on how to solve the problem?

Pasting our skype discussion here, for future reference to others as well.

create a new camera, which is orthogonal.
then, you need to make a new layer, and set the layer of that on the animated object (which represents the cracked view).
(you can keep that to scale 1, because we are wrapping the camera to fit that, instead of the other way around)
Make sure the camera only renders the layer that the animated object is in.
then, on the animated object, attach this code:

public class cameraBoundScale : MonoBehaviour {
 
 public Camera scaleCam;

 // Use this for initialization
 void Start () {
  scaleCam.orthographicSize = renderer.bounds.extents.y;
  transform.localScale = new Vector3(scaleCam.aspect, 1f, 1f);
 }
}

and in the editor, drag the ortho camera to the scaleCam parameter.
if you then start, the animated object is perfectly scaled 1:1 to whatever screensize you have.

This sets the height of the camera to fit the object, and then scales the objects width to fill the bounds that are left over (so you might see some scaling on the object, however if you Graphics.Blit the render texture onto it’s UV’s, you shouldnt see stretching anyway).

regards,
-D.