Does anyone know how to put multiple cameras into a craft scene and then choose which one renders the scene?

Hi. I would like to try adding a craft.camera component to each of the 3D models I have in a scene and have each camera aimed at its associated model so that I can then move each model and have the particular craft.camera component attached to that model “follow” that model and render the scene in a 3rd person view looking at its attached model. I then would like to press a button and switch to having another camera attached to another 3D model be the active camera to render the scene looking at that other 3D model in a 3rd person point of view. I’d like to then set up the project so that as user chooses another camera and its associated 3D model, the user then can control the movement of the model. I think I can figure out how to attach a craft.camera to each 3D model but can’t tell from the reference how I would switch to turn one camera on to render the scene and another camera “off” and not render the craft.scene. Has anyone figured out how to do that?

If so, I’d appreciate if they could share their code that accomplishes what I asked and/or their example project where they switch which cameras are active and render the scene.

Thanks!

You can use entity.active = false on the camera’s you don’t want to draw at any given time which should stop them rendering

Thank you very much for letting me know, @John :slight_smile:

1 Like

@John,

Strangely, making my cameraEntity.active = false doesn’t seem to turn off the camera in this snippet of code:

PirateCamera = scene:entity():add(craft.camera, 20, 1, 10, false)
PirateCamera.parent = Pirate
PirateCamera.active = false

(Although making entities such as my 3D Model Pirate.active = false does make those entities invisible).

Is there anything else I should be doing to turn off the cameraEntity I made?

Thanks :slight_smile:

Ah ok, I’ll try testing this out and see if whats up