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:
Thanks for your time!
I see two possible solutions.
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 :)
answered Jul 11 '18 at 01:29 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here