How do i make a switch between two cameras

what are the codes and where should i put it if i want to make a switch between two cameras? can anyone help?

Hi @marymarzx,

To switch between two cameras the idea is to disable the active one, and enable the other.

Here is some example code using entity names to find the entities in the hierarchy, enable Camera2 and disable Camera1:

const camera1 ='Camera 1');
camera1.enabled = false;

const camera2 ='Camera 2');
camera1.enabled = true;

There is even a official PlayCanvas tutorial on toggling active camera views:


Project Scene

1 Like