Camera change

I would like to know how do I switch from one camera to another.


I wanted to change FPS camera to third person in game

Hi @naillywtsu_TT,

Setting children equal to true isn’t correct, and it will also break your application most likely.

To enable/disable an entity use the .enabled property. That property can be set equal to true/false.

Also to have this run only once, instead of using isPressed use wasReleased.

// --- this will disable the entity the script is attached on
if(this.app.keyboard.wasReleased(pc.KEY_S)){
   this.entity.enabled = false;
}

To re-enable it you can use an event e.g. firing from another script. Check this manual page on how scripts can communicate:

https://developer.playcanvas.com/en/user-manual/scripting/communication/

1 Like