[Solved]How to switch between first person camera to third person camera and vice-vesra?

Hi all, is there a way to switch between third player and first player character controller in game at runtime with logic or trait ??

Yeah, you can do it, the way to do it would be to move camera from first person to third person or vice-versa.
Create 2 empties and place 1 empty near first person view and second empty near third person view, then using logicnodes/haxe script change camera position from one empty to other empty using some inputs.

2 Likes

If you use the Armory updater to get the latest version of the SDK, you could also use the change camera node to change between the first and third person cameras:

image

1 Like

Code:

// ...

var camera:CameraObject;

function init() {
// ...
camera = iron.Scene.active.camera;
// ...
}

function update() {
// ...
var keyboard = iron.system.Input.getKeyboard();

// default camera position
if (keyboard.started("1")) {
camera.transform.loc.set(
camera.transform.loc.x,
-5.0,
camera.transform.loc.z,
camera.transform.loc.w);
}

// other camera position
if (keyboard.started("2")) {
camera.transform.loc.set(
camera.transform.loc.x,
-8.0,
camera.transform.loc.z,
camera.transform.loc.w);
}

// ...
}

// ...
2 Likes

Thanks a lot guys ! this will help me to continue my project

3 Likes

Yeah, necro, but I can’t find anything on this:

Is it possible to interpolate smoothly between cameras and
not jumping instantly from one to another?

Yes, check the bundled trait follow camera, the logic of this maybe can be repurposed for what you need

if not, check the tweening example https://github.com/armory3d/armory_examples/tree/master/tween, I think it’s a little bit outdated to the current changes but more or less gives you the idea.

4 Likes