x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Panning camera using blueprint

I'm currently trying to pan a camera in the side scroller template, but so far with no luck. I've managed to it to detect when it reaches the edge of the screen using a blueprint from another thread here. I have not managed to find anything that tells me how to pan the camera once I move to the edge of the screen. I'm looking for something like the League of Legends unlocked camera, but usable in the side scroller template. If anyone could provide me with an explanation or even just a screenshot of how to continue what I currently have to get it working, that would be great. Thanks in advance.

alt text

Product Version: Not Selected
Tags:
more ▼

asked Dec 19 '14 at 10:13 PM in Blueprint Scripting

avatar image

youraveragemoe
50 2 7 12

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

That looks quite good. Now let's think how this could work.

You need a way to determine where the camera should move. You get a boolean out of your setup however you don't really want to check with branches if you are overlapping two of those at once (I assume you don't want straight up, down, left right movement but also diagonal).

I do this by creating a temp vector which I set each frame by +1 or -1 in X or Y depending on which branch triggers.

The result gets fed into a function inside of my character.

alt text

Inside of that character I have the camera attached to a spring arm and then move around the spring arm in this function. That's pretty straight forward. It looks like this:

alt text

I hope this helps :)

Cheers

controller.png (494.3 kB)
hero.png (136.9 kB)
more ▼

answered Dec 19 '14 at 11:04 PM

avatar image

Erasio
5.9k 291 86 293

avatar image youraveragemoe Dec 19 '14 at 11:10 PM

I'll try that out later and see how it works. I'll probably do it tomorrow morning, so I'll let you know then. Thanks for the suggestion!

avatar image youraveragemoe Dec 20 '14 at 12:58 AM

Would you mind posting pics of the rest of that BP? I set up what you've shown me, but it isn't doing anything right now.

avatar image Erasio Dec 20 '14 at 01:06 AM

If you've set it up like I did, did you remember to set the speed?

Do you have the camera placed as child of the spring arm? (one level lower in the hierarchy tree... I lost how it's called :S)

Because I don't really have anything else in the bp...

Well I do but nothing regarding the unlocked camera.

avatar image youraveragemoe Dec 20 '14 at 01:09 AM

whats the name of the speed variable again? and what do you have it set to?

avatar image Erasio Dec 20 '14 at 01:14 AM

Well in my case it's just a static variable which I set in the controller and in the function I directly input it into the Vinterp to constant.

In the controller class you can see it at the right just before calling the function inside of my character.

avatar image youraveragemoe Dec 20 '14 at 01:26 AM

I think my problem might be my camera. It doesn't seem to be doing anything

avatar image Erasio Dec 20 '14 at 01:29 AM

Could you post a picture of your movement and the components tab?

That would make things easier than to guess every possible thing you or I have overlooked :)

avatar image youraveragemoe Dec 20 '14 at 01:31 AM

I'm like 100% sure I have my components are the problem

alt text

avatar image Erasio Dec 20 '14 at 01:36 AM

You have to create a character or a separate Camera which you add to your character.

The controller does not have a location and all that stuff.

avatar image youraveragemoe Dec 20 '14 at 01:44 AM

Sorry, I'm still kind of new with UE4. Would you mind showing me what your components tab looks like?

avatar image Erasio Dec 20 '14 at 01:48 AM

Pretty much the same. That's not the issue.

The issue is the parent BP.

You need a BP with the parent "Pawn" or "Character". Not Controller.

You will have to create a new BP for the camera usually being the same as your main character (be it a character or vehicle or something completely different).

avatar image youraveragemoe Dec 20 '14 at 01:48 AM

Ok I'll try that

avatar image youraveragemoe Dec 20 '14 at 07:09 PM

If I could just ask you another question. What is the view movement margin? what is it supposed to be set to?

avatar image Erasio Dec 20 '14 at 07:21 PM

In my example it is representing the margin at the border of the screen in which the camera will move in percent (because I'm doing the percent calculation in that percent node).

A good value for testing was 5. For the actual game I keep it around 1-3.

avatar image youraveragemoe Dec 20 '14 at 07:26 PM

ok. And another thing. Would this work if I put all of it into a pawn blueprint? or do I have to put it into a controller and a pawn?

avatar image Erasio Dec 20 '14 at 07:45 PM

You can definitely do everything in the pawn.

I just split this functionality because I like to keep everything input / responsiveness related stuff in the controller and only keep directly character related stuff inside of that one.

But that is merely a thing of how you want to structure your BPs ;)

avatar image youraveragemoe Dec 20 '14 at 07:48 PM

Ok I have it working now. Only 1 issues though. When I go to the bottom of the screen it doesnt move.

avatar image Erasio Dec 20 '14 at 07:57 PM

Well then there has to be something wrong with either the way you use the resulting boolean or with your calculation before that.

avatar image youraveragemoe Dec 20 '14 at 07:58 PM

Oh my god I'm so stupid. I forgot to hook up the true result from the branch...

avatar image youraveragemoe Dec 20 '14 at 08:03 PM

It works great! thanks so much for your help. But before we part ways, may I ask if you have it so that the camera doesnt move off the map when you go all the way down?

avatar image Erasio Dec 20 '14 at 09:02 PM

Not right now.

I would probably create two variables with vectors and check if it's within them.

And simply set it from the levelblueprint.

If you want it more complex it would probably be worth it to convert your main actor into an AI controlled entity which you command from your controller and have your character be a camera only character which you could then block with volumes.

avatar image youraveragemoe Dec 23 '14 at 08:53 PM

Hey man just wanted to ask if you managed to find a way to get the camera to stop once it gets to a certain point on the map (e.g. end of the map)? I've been trying but so far no luck.

avatar image sarchasm Jun 16 '16 at 08:01 AM

Instead of mouse position I want to use player position, can I just break the location vector and get the x and y? Or is the position relate to the screen?

avatar image Erasio Jun 16 '16 at 11:19 AM

Use player position for what?

Do you just want to have the camera follow your player character? Attach it! Create a camera boom with a camera as child, make the settings you want and you're done!

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question