β˜‘ How to have two viewports displaying?

I need to display two viewports, each for a different camera (two cameras).

Can this be done? How?

There is a viewport property on camera, simply try playing with it.

I’ve created an example project that displays multiple viewports using multiple cameras here: https://playcanvas.com/project/443666/overview

It’s due to be added to the tutorial section.

2 Likes

Steven,

I am trying to understand how you got it to have multiple viewports on the same screen. There seems to be no code or documentation. Could you please explain how you are doing this?

Is it possible to set this with code on the fly?

If you want to change it on the fly, pc.CameraComponent.rect is the property you need to look at: https://developer.playcanvas.com/en/api/pc.CameraComponent.html#rect

In the editor, the property viewport is the property to change:
image