I was recently introduced to a powerful tool in UE4 called the Timeline. All of my previous articles were created without any knowledge of this tool, but now I cannot ignore the fact it provides simpler and more robust solutions than my previous attempts. This weekend was devoted to creating a platformer style camera that is modelled after Tomb Raider 2013 as a warm up for using timelines. There will be no ledge grabbing, vaulting, climbing, or ice-picks in my prototype - so only jumping and landing from a drop will be covered here. My starting point is the default Third Person Blueprint in UE4.10.3 with no modifications except to create a basic test level that has a lot more jumping and height differences. (Aside: In full scale game production, this level would have all the different sizes and shapes - often called metrics - that the avatar could traverse. so locomotion systems, animations, camera, and controls could be tested before the game world is created).
- "Minimize unintentional camera motion whenever possible. This is especially true of cinematic sequences, but it is true to say that camera motion should be avoided unless it would either result in the camera being left behind by the player character, or the camera interpenetrating the player character. Slight or unintentional camera motion caused by reactions of the player character to environmental factors (or noise from player controller inputs) should be avoided. Similarly, if camera motion is directly linked to that of the player, it often results in an "unnatural" or "stiff" feeling camera.
- Ensure camera motion is smooth. Smooth, frame-coherent motion of the camera is necessary to avoid disorienting or distracting the player. Of course, smooth motion is normally achieved by velocity dampening, which has the adverse effect of allowing the target object to either accelerate away from the camera or worse, overtake and interpenetrate the camera. Nonetheless, smooth camera motion is of great importance and there are techniques available to assist the camera in cases where the player character is subject to rapid acceleration. Low-pass filter can help smooth out irregularities in movement especially when the camera motion is tied directly to that of the player character, where noise from unwanted player input may cause slight motion."
|
The opposite effect is achieved in Tomb Raider when Lara Croft lands a jump, but the camera still has smooth motion throughout the landing.
The first rule of timelines is they can be used on Actor Blueprint Graphs, but NOT Actor Component Blueprint Graphs or Scene Component Blueprint Graphs. This can provide a conceptual barrier for someone who has not used them before, especially when it seems like adding a timeline to a Scene Component Blueprint Graph is the ideal solution. After realizing this limitation, I arrived at two possible options, and chose the latter after running into issues with the former:
- Run the timeline on the ThirdPersonCharacter to provide an intended location to the ThirdPersonCameraTarget, which parents a CameraBoom with a FollowCamera child.
- Run the timeline on the ThirdPersonCameraTarget by making it a pawn, completely separating the controller for the camera from the controller for the avatars movement.
For those interested in a simple solution, UE4 provides an easy way to achieve smooth movement to improve on the "stiff" feeling default camera. Lag properties on CameraBoom can be tuned in ThirdPersonCharacter to quickly provide a smoother camera.
After unhooking the camera movement from the character movement
There is a Scene Component on my ThirdPersonCharacter called CameraHitch that the ThirdPersonCameraTarget should follow. Using AttachTo with Snap To Target defeats the purpose of this exercise, but serves as a good intermediate to test that the previous steps of implementation are working. To move beyond this implementation, I have to start communicating the location vector of CameraHitch to the ThirdPersonCameraTarget blueprint.
I also want to communicate when the ThirdPersonCharacter loses connection with the ground to the Camera Controller, and apply a special form of lag to accentuate the impact. Using the jump input as a trigger event is not the correct implementation because it will not show the special lag if the player runs off a high ledge without hitting the jump key. Thankfully, UE4 GetMovementComponent on ThirdPersonCharacter pawn followed by IsFalling returns true exactly when we want it to. Do not let it's name confuse you because IsFalling is true even as the player jumps upward off the ground.
The True output from this "Player HasLanded" Branch goes to the timeline ZGrounded in the image directly below this one.