after several attempts and trying many different tutorials I would like to ask you for help.
In order to learn UE4 I want to create a mini game in which a player can move up, dow, left and right. The player himself controll a ball (which moves forward automatically) and shall try to reach the end of a pipe. In the pipe several obstacle will spawn which then the player needs to dodge in order to finish a level. So far everything works without any problem but now I would like to add a bended pipe and that is where I face an issue.
My issue is that at some point in the pipe the camera would need to rotate (see figure 1)
I have tried several youtube and text tutorial to attach the camera to a player and even for making a camera following a spline. However, none of them have worked for me so far. Do I really need to add a spline in each pipe ? Wouldn’t this be problematic since the pipe is build dynamically (when hitting the triggerzone).
I had another idea how I could approach this issue but I am not sure if it usable. My idea was to create a second tigger zone at t2 (see figure 1) and as soon as the player hits the trigger the camera will be adjust automatically. But here again how could I achieve this without moving the camera too fast ?
I hope you guys have ideas or suggestions how to achieve this simple (I guess) taks.
Here are some further details of the project :
Blueprint:
BP_PipeSpwaner (responsible for spwaning the pipes.)
BP_Player
BP_LinearPipe
Bp_BenbdedPipe
If my problem is unclear here is a video of monkey ball: Super Monkey Ball is getting its "Sonic Mania" moment — ROLLED OUT - YouTube
In the first few seconds of the viedo (at the selected time code) one cann see that the player controls the monkey ball on a bended road and that the camera follows the player.
…this might seem like a too simple response, but I think it may work for what you are trying for: On your player character / pawn have you considered a spring arm / camera setup… (one the spring arm with inherit yaw, and adding camera lag and camera location lag as you need for smoothness)?
So, my idea is that you could let the camera face towards the forward movement, for it to turn automatically around corners, basically turning as the velocity is influenced by the turn itself.
(5 FPS GIF incoming)
What you see here is a cube spinning in the direction of velocity.
You could use that to rotate your spring arm (on event tick) for example.
It’s probably not perfectly what you want, but should be a start.
One of the kinks you’d need to iron out is, that it isn’t stable if velocity is x0y0z0.
(oh and it probably doesn’t work well if your camera relies on the pre-built control rotation, which I would kill off anyway if you want some more freedom)
first of all thanks for you answers. I tried to use spring arm / camera setup as suggested by @aNorthStar and @Aphermion. While I was trying to use this approach something else came up to my mind. The player is only able to move along the Y-Axis (left and right) and Z-Axis(up and down) but he is not able to a yaw, pitch or roll (since he is moving automatically on the X-axis). In other words, even if I would be able to move the camera it would be useless since the player is always moving forward on the X-Axis. So if I get it right this would mean that I need to rotate the pipe itself instead of the camera, right ?
I did a first try where I just rotate the pipe at t2. In fact this worked but wasn’t smooth enough because one could see the player “bouncing”. So now I have the Idea that I could rotate the pipe a little bit at each frame. Since for each pipe I have a own mesh I could add a scene somewhere in the pipe (just like t2 in the figure) and depending on the position of the scene, the start point of mesh and the velocity I could calculate an alpha-value and then depending on this alpha-value rotate the location every frame. What do you guys think of that ? Is this a option? Or is there a simpler approach ?