Hello. I need some help. I have created two camera types: a default third person camera ( FollowCamera ), that I modified and made another one - a first person camera ( named FollowCamera1 ). I want to toggle camera types using “C” keyboard input key - so when I start the game, the engine uses my default camera named “FollowCamera”, then when I press “C” engine switches my view to “FollowCamera1” , when I press “C” again, view changes back to “FollowCamera” and so on…
Can somebody show me a blueprint example, or give me a hint how to create it ? Thank you
You can use the node “Set View Target”. Just reference the camera you want to use. Add a bool or check which of those two is your current view target and on C change it to the other one. That should do the trick
Hi ! Thank you so much ! Do I have to create two variables of boolean type referencing the two types of my cameras ? My current view target is default camera named “FollowCamera”. Can you make a more detailled explanation please ?
If you only plan two cameras one bool is quite enough. You just want to check where your camera currently is. Let’s say 0 for the followCamera and 1 for the followCamera1.
Then simply have a branch, change the bool and set the target.
I mean what exactly is your issue right now? It’s fairly straight forward. You simply have to use this “Set View Target” node on your key event (c in this case).
Well in that case you probably don’t want a bool but probably an array existing of all your cameras and an int. You can then just compare your int with the length of your camera array. If it’s larger or below 0 you can then set your int to 0 or the length of the array or if it’s not below or above the array size just add / subtract one and simply set your view target to the index of the array where you use your int variable as input.
Like this you can insert as many cameras as you want.
Hi, I am a real novice in BP to be honest. I have given itself such shot but I cannot link the followcamera or followcamera1 with target in “set view target with blend”.
Can somebody please give me more detailled explanation for the BP setup for two camera types ? Thank you in adv.
First of all right now you can’t change between two camera components in the same BP. You will need camera actors which are not available in BP. (just found that out myself… It’s possible in C++ though).
Anyway to change this it will be quite a bit of other work because you can’t simply add it to the actor BP itself in the components which means you’ll have to code the movement of them as well.
To make this easier for you I’d suggest if you “only” want a few different angles to do this via a spring arm. Change it’s length and you pretty much have a 1st - 3rd person camera change.
Doing that is actually very straight forward. It’s just “Set Target Arm Length” (I checked this time. It’s there and works exactly as expected).
Take care that your camera is a child of your spring arm so its location depends on the spring arm.
I’m really sorry for my mistake. I really thought this was possible straight forward like I explained in BP and was too lazy to check. That was quite horrible in this case. Sorry.
If I’m understanding your question, then you’re in luck! If you create a new project based on the normal Vehicle template you can find all the example blueprint code you need to do this.
It is already setup to use two different cameras and you press the Tab key to toggle between them. Go into the Sedan blueprint to see how it’s done.
Ok, I have looked into sedan blueprint, but looks like it’s based on the nodes I can’t really cast. I have three cameras, ( 3rdpersoncamera - a default camera, 3rdpersonactioncamera and 1stpersoncamera .
I made a “toggle camera” function, that is activated with “C” button - this already works. When I push “C” then the viewport automatically changes to 1stpersoncamera ( as next following active camera ) ( toggle camera → deactivate 3rdpersoncamera ).
Can somebody explain me how Can I force engine to:
deactivate the default 3rdperson camera and activate 1stpersoncamera after “C” button is pressed
deactivate the 1stpersoncamera and activate the 3rdpersonactioncamera after “C” button is pressed again
deactivate the 3rdpersoncamera and go back to default 3rdpersoncamera afrer “C” button is pressed for the third time