Switch camera via blueprint by button press

Hi

I’ve tried working this out and can’t find anything specific on the answer hub (or I’m not looking hard enough).

What I’m trying to do it have it so that I can play the level through a camera and then switch between cameras.

I’ve got the initial set-up of running the level with 1 camera.

I’ve only been able to find out how to do this with using trigger boxes,which I’m not using.

Here is a screenshot of my current level blueprint.

Thanks

Daniel

What button press do you want to map it to?

For example, to map it to spare bar, you right click and add “input space bar” and hook it up to your set node. You could possibly use a multigate to make it so each press swaps between cameras.

That should be pretty easy as well. So many ways to tackle it. If you only have a handful of cameras I’d go with “Switch on Int” and then store an Int of your current camera. Then on left subtract 1, on right add one. You could make it looping by checking if you go over, or (more elegant) by using modulus to automatically make it look using math.

Well ideally I would want it to go back and forth with the arrow keys…

But I’ll try what you suggested, see if I can get that working first before I make a mess of it.

Edit: Thanks that works, now I can play around with it.

Well I’m fairly new to using blueprints.

I was just able to set it up using another mutigate and reversing the pin order.

http://i.imgur.com/4pqwxjf.jpg

Don’t suppose you could show me a screenshot of the your method?

Thanks

That works but probably will not start at the right location when you switch directions at different states.

Try something like this:

the ++ and – nodes are called “increment” and “decrement”

Also note we are doing mod 4 since there are 4 output pins counting 0.

Thanks

I’ve got that set-up, however it won’t let me cycle both ways, I can only cycle though using one arrow key.

hmm that is strange. if you debug, are both events firing?? There should be nothing about the script that cares where it came from.

If you are unsure how to debug, after starting PIE, in the BP window you should be able to select an instance of your BP in the upper right in a drop down then the lines should highlight when you press buttons

Both events are firing but only the one through the Increment change the camera, the Decrement does nothing to change the camera, the lines just fire through to the current camera.

hmm that is very odd. and you are sure the decrement one is hooked up to the “switch on int” node just like the increment one? Ill try a test here in a bit.

edit do absolute after the %. you are probably just stuck in negative numbers which is always returning 0 :slight_smile:

I’m pretty sure I’ve set it up right (lay out is just different).

http://i.imgur.com/llBVxyc.jpg

Do absolute int after the % node. It is just stuck returning negative numbers once you go to the left of 0.

You may want something different if you need to avoid the symmetrical behavior this causes around 0. Should be easy to check for if you need to. maybe just start the int at like 5billion :slight_smile:

So have teh % node > into the absolute int > into the switch on int?

If so, still not cycling both ways.

The value coming out the absolute node goes up between 0-3 when increasing (right arrow) but not down when decreasing (left arrow).

Also the number going into both the ++ and – constantly goes up (up to 55 for example).

Not sure if it matters but I left the integer at it’s default value 0, I tried changing it, but had the same result.

Yes, I just set it up here exactly the same and it is working. If your is not working for me, hover over the value coming out of the absolute node and see what it is as you change both ways.

Also does it work if you set the default value of ‘int’ to be something large like 1000? Then left will cause it to be 999 instead of -1. probably not the issue but worth a try.

ok strange. so what happens to the value coming directly out of the “decrement node” after each left press? Is that not chanigng? seems that way which is odd.

if so you could bypass it and use int = int - 1

Well seeing as the increment and decrement don’t plug into anything (only the execute part) I can’t see what value comes out of them.

Also what do you mean by use int = int - 1?

When I hover over the blue (cyan) circle on the right side of the “decement” node there are no values same with the increment.

And using set in with -1 doesn’t work either

I mean hover the mouse over the blue circle on the right side of the “decement” node and then press buttons and make sure the execution lines fire and see if the value is actually decrementing on left press.

And I mean doing it manually by doing “set int” and then using “int - 1” as the set value.

Those both set the value of int before the switch. Then the switch reads the modified value of ‘int’ with the modulus calculation performed on it.

Puzzling. You had it like this?

as soon as I press left it goes to -1 then keeps going more negative.

If I was having this much trouble, I’d also add “print string” on each press after the “set” to read out the value of int on the screen.

“int” was probably a bad example name for a variable btw… “CurCamIndex” or something would be better.