blueprint

Paperboy BP_Player EventTick (Camera) 210260

  • Exposure: public
  • UE Version: 5.0

TobiyC

January 18, 2023, 4:28 pm

Click the button above, it will automatically copy blueprint in your clipboard. Then in Unreal Engine blueprint editor, paste it with ctrl + v

1 comment

  • TobiyC

    January 18, 2023, 7:11 pm

    This section of the BP_Player blueprint relates to the EventTick node. Because you can't have multiple instances of the same starter node, three separate features are put together as they all rely on the EventTick node. The simplest is "Updating Ammo and Lives for UI." All this simply does is check what the "Ammo" and "Lives" integer variables are, and make the UI align with it by using the "UI Reference" new widget variable, which is the UI widget.

    "Move Player Every GameTick" does what it says on the tin, it ensures the player is always moving forward a little bit every tick. It takes the forward vector of a 45 degree arrow and multiplies it by (player speed x 550.) Player speed is multiplied by 550 after trial-and-erroring to make Paperboy move forward enough. This new value is is multiplied by Delta Seconds so it is frame rate independent, and this final value is plugged into the 'AddActorWorldOffset' node to make Paperboy move at least a little bit every tick, even if there are no inputs.

    The camera blueprint is a little harder to explain, but what it results in is the camera being clamped if Paperboy moves too far left or right of the main path. The first comment calculates the 45 degree angle based on Paperboy's X-axis position. The second comment calculates the maximum horizontal movement from Paperboy's position and clamps the Y-axis of the value if he goes outside of the clamp variables. The third comment adds the calculated vectors of the first two comments, adds them, and adds a manual offset, then plugs the final value into the 'SetWorldLocation' node.

    "CameraClampLeft" is a float variable always set to -60. "CameraClampRight" is a float variable always set to 500. "Offset" is a vector variable always set to X=-700, Y=-300, Z=1000