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


#1

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


#2

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.


#3

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


#4

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);
}

// ...
}

// ...

#5

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