Download

Creating a camera zoom function for a gamepad.

Howdy,

I’ve been watching a lot of tutorials and I seem to have figured out how to zoom the camera in and out on the player using the mouse wheel. Thanks to @Tesla Dev for that one. It’s a little jumpy, but it’s fine.

Now I’m interested in something similar for the gamepad. Here’s what I had in mind: like in some Bethesda games, the player would zoom/expand the camera by clicking the right stick and pushing it forward or backward. I tried my own hand at this but didn’t really get anywhere. I have a feeling I’ll need to delve into axis and vectors and such and I’m not much good with those yet.

So, any advice?

So this video kind of talks about setting gamepad controls using axis events. It’s not so bad especially if all you are doing is zooming in and out. You may need to dig to find the tutorials that set up the initial events, but actually utilizing them seems pretty basic.

Good luck!

https://www.youtube.com/watch?v=TinFTxeXDho

Thanks for the link. I’ve seen the videos before, but they did help.

I’ve reworked the thing, but it still doesn’t quite run. Here’s how it looks in the MyCharacter Event Graph:

384f935ab595538f89a7c466765dfab6231342c0.png

It’s not very pretty – I had to scrunch the nodes together to fit on the screen. Am I on the right track here?

Oh boy that BP is rough, but I suppose that’s what happens sometimes! Ok let’s see.

First, to clean this up you should bring the getter, its connected nodes out through the setter including the clamp and camera boom up over the gate. That way you won’t have crossed wires. Crossed wires make working impossible.

Second, there’s some strangeness around here. I agree that you want to multiply the delta seconds times the “lookuprate” which I guess would be the zoom rate but tying in the section with the camera boom and target arm length I think is where I’m getting confused. You want to set the target arm length to be the lookuprate X deltaseconds X basetargetarm. So if I’m 5000 units away and I zoom at 400 units per second for 2 seconds I’m now only 4200 units away. Then you have to copy and paste that same situation but in the reverse because if I zoom OUT for 2 seconds I should be 5800 units away.

Also, the Gate is not necessary or at least I don’t think it is. I think you may be over-complicating this BP a bit.

However, if you do want to be classy you get set that empty setter you have there to reset your target arm length back to the base value when the joystick is released. That would be neat :slight_smile:

Does this help you at all? I think you are getting there, this is definitely the right path.

EDIT: OH dear lord, I just watched that video I linked you. Even Unreal devs suffer in BPs sometimes. Laughing.

Thank you for the advice. I’ve made some changes, but I’ll be honest – I’m not understanding everything you’re saying. I’m very new here, I’m afraid.

However! I have tinkered around a bit with things and have a better setup. Now I can reliably zoom the camera in and out, but only in little chunky bursts. I still don’t know how to implement an axis value.

Here’s the refined stuff, with slightly less headache:

447bd8d352b18aa9b2a3e6a37e8867652e9a476b.png

I think I’m closer to what I want, but I’d welcome more input.

OH my goodness that is a BEAUTIFUL BP. You absolutely should be proud of this.

So getting it to zoom in bursts means you need to adjust some numbers. I’d start with that base look up rate. You are probably moving very quickly and just hitting the clamp value very abruptly.

Just for your sanity, you don’t need those branches. You can drag “pressed” directly to “set” and sort of clean it up even further. It’s your call, but I figured I’d let you know.

Thank you for the compliment, that really raised my spirits.

I’m afraid I don’t follow what you mean with the rest, though. I tried changing the values of the base look up rate, but 10 or 100 or 1000 it makes little difference. Also, if I remove the branches the whole thing kind of breaks down. I think I’m going to need to use something like Gamepad Right Thumbstick Y-Axis to get the smooth transition I’m interested in, but I’m not proficient with those yet.

Hmm, honestly I don’t use gamepad controls so this is just all my speculation. If you go ahead and use the Axis controls you will likely get a better outcome, I agree. They aren’t scary it’s just that gamepads have a dimension mice don’t. It only really affects the Y-Axis so you are correct here in that you only need to care about Gamepad Right Thumbstick Y-Axis. The input is your setter at the end there, that float value.

If you grab it, you’ll see it’s a function call that has an input of an actor ref and an output of a float which is that new camera boom location. It’s super simple and likely the missing piece.

Well, I’m sorry to say I’m just not getting it. Leaving it as it currently stands, the system is passable. I want to figure this out eventually, though.

Hi did you find a solution to implement an axis value ? I managed to do it but the zoom is not smooth and i dont know why …

Finally i find a way using the timelinenode.
I can post a screenshot if someone is interested …

I’m not sure if anyone still wants this, but if not I’ll post it here for reference.
*note, for this to work as is, I moved the camera’s - spring arm up to the head of my character

23e19a01354268b4f2f41519f59f8279f5457fcd.png