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"

Need help moving camera to the side

Hello, I need some help if thats possible!

Im doing a runner game with 3 lanes, the lane swap is working and i did it by giving a number for each lane (-1; 0; 1). I want to use this number to detect when to move the camera some units to the side. For some reason what i did isnt working.

I have a var (CameraOffset) that changes value when im in the correct lane, but the camera isnt moving at all, i think its better if you see the blueprint:

https://blueprintue.com/blueprint/g2qxb9nm/

Thanks for your time!

Product Version: UE 4.19
Tags:
more ▼

asked Jun 16 '18 at 10:19 PM in Blueprint Scripting

avatar image

IvoMR
23 1 7

avatar image VortXGaming Jul 11 '18 at 01:12 AM

Hello IvoMR,

I am not sure what the correct answer is, but what I would do is try to change directly the position of the specific camera actor which you are using in your level. So I suggest you change the part in your blueprint that you are using a variable to access the CameraActor(I am talking about the target that is connected to the SetActorLocationAndRotation node) and just drag and drop the camera actor from your level. Then you are going to see a node with the name of your camera actor and below this "from persistent level". I think it is worth a try, and I hope I helped you.

Good luck alt text

camera.png (49.0 kB)
(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

tl;dr

I see two possible solutions.

  1. if you have a player object that already moves from lane to lane, then parent camera to that object, it will move to the lane, when the player moves

  2. if you don't have an object that already moves from lane to lane, then try checking whether SetLocationAndRotation is being called at all. If Direction variable is not set to Center then it might not be

Longer version

Hey, I'm not that proficient with the blueprints, but let's see if I understand yours correctly.

You remember which lane you are currently in (Switch on Name, or is it where you wanna go?) and in every frame you set position of the camera based on the player's position. If this is the case, I might have a bit of a trouble understanding how you swap lanes if you are not in Center lane. What purpose does it serve in first place?

In the second part you change variable CameraOffset that you use to move the CameraActor. I'd probably check whether CameraOffset changes each frame (see what you are plugging into Make Transform node) just to be sure. This should also help you check if the SetLocationAndRotation method is being called at all.

I see a possible problem here, but can't see if it's "it'. When does the "Direction" changes (Left, Center, Right)? Is it when player moves from lane to lane, or when camera does? Does it change at all? If it changes when player moves, then it might be that the methods to change camera lane are never called.

If this is true, then there's a couple of solutions that might be more efficient for you. Thing is, there's no need to do the lane swapping in Tick function (and it's a good practice to only keep functionality that can really differ on per-frame basis in Tick for performance reasons). Instead, you can move the camera in the same function where you change CurrentLane variable (or wherever you change Direction variable). This will only get called when necessary (I assume when player pushes a button)

However, if you already have a player object that you can move from lane to lane, try adding the camera to the blueprint of the character. This could save you lot of trouble, as the camera will move every time the player moves (that is in any direction). Check Third Person Character to see how it can be done.

Hopefully this helps you, and hopefully I got what the BP does for the most parts. Cheers :)

more ▼

answered Jul 11 '18 at 01:29 AM

avatar image

ex3me
78 4 5

(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