ATK_MainCamera - golden-coconut-studio/TikiAdventuresWiki GitHub Wiki
- This is the Main Camera used in our game. It's based on a rail based camera, with some specifications, like the ability to change zoom options, field of view, angle of rotation (to follow tikis around the map) and change from one position to another of the map. It uses the system of hexagons and property points.
- Main Properties
- TK_MainCamera - General
bUseBasicBehaviour (DisplayName = "Use Prototype")
- Type: bool
- Default: false
- EditAnywhere
- BlueprintReadWrite
- Enables the behaviour of the prototype, disabling rotation, zoom and transition between points.
bCanZoomInOut (DisplayName = "Can Zoom")
- Type: bool
- Default: true
- EditAnywhere
- BlueprintReadWrite
- If true, zooms in/out when Tikis get too close or too far from one another
bCanAlignToTikis (DisplayName = "Can Rotate")
- Type: bool
- Default: true
- EditAnywhere
- BlueprintReadWrite
- If true, can rotate to keep Tikis in sight
bCanTransitionBetweenPoints (DisplayName = "Can Move")
- Type: bool
- Default: true
- EditAnywhere
- BlueprintReadWrite
- If true, can move to next CameraPoint on the map
Camera
- Type: UCameraComponent*
- EditAnywhere
- The camera with all its properties, in case design wants to change any of them that are not already on custom editor.
- TK_MainCamera - Zoom
DefaultCameraArmLength
- Type: float
- Default: 400.0f
- EditAnywhere
- This property can be changed only if "bCanZoomInOut" is false.
The next properties can be changed only if "bCanZoomInOut" is true.
bCanChangeFOV (DisplayName = "Can Change FOV")
- Type: bool
- Default: true
- EditAnywhere
DefaultFOV
- Type: float
- Default: 90.0f
- EditAnywhere
- Clamp: [60, 120]
MaxFOV (DisplayName = "Max FOV on ZoomIn")
- Type: float
- Default: 90.0f
- EditAnywhere
- Only editable if "bCanChangeFOV" is true
- Clamp: [60, 120]
MinFOV (DisplayName = "Min FOV on ZoomOut")
- Type: float
- Default: 60.0f
- EditAnywhere
- Only editable if "bCanChangeFOV" is true
- Clamp: [40, 80]
MaxDistanceArmLength (DisplayName = "Max Zoom Out")
- Type: float
- Default: 1000.0f
- EditAnywhere
- Clamp: [400, 1200]
MinDistanceArmLength (DisplayName = "Min Zoom In")
- Type: float
- Default: 600.0f
- EditAnywhere
- Clamp: [100, 800]
- TK_MainCamera - Rotation
DefaultCameraRotation
- Type: FRotator
- Default: (0.0f, 90.0f, 0.0f)
- EditAnywhere
- This property can be changed only if "bCanAlignToTikis" is false.
The next properties can be changed only if "bCanAlignToTikis" is true.
bCanAutoAlignVertical (DisplayName = "Can Rotate Vertical")
- Type: bool
- Default: true
- EditAnywhere
DefaultVerticalAngle
- Type: float
- Default: 30.0f
- EditAnywhere
- Only editable if "bCanAutoAlignVertical" is false
- Default angle in which the camera will stay VERTICALLY
AngleCamera (DisplayName = "Max Rotation Angle")
- Type: float
- Default: 20.0f
- EditAnywhere
- Max angle in which the camera can rotate HORIZONTALLY
- TK_MainCamera - Transition
These properties can be changed only if "bCanTransitionBetweenPoints" is true.
bCanChangeHexagon
- Type: bool
- Default: true
- EditAnywhere
- BlueprintReadWrite
StartingHexagonIndex
- Type: int
- Default: 0
- EditAnywhere
StartingCameraPointIndex
- Type: int
- Default: 0
- EditAnywhere
WaitTimeUntilTransition
- Type: float
- Default: 0.0f
- EditAnywhere
TimeTransition
- Type: float
- Default: 3.0f
- EditAnywhere
FloatCurveTransition
- Type: UCurveFloat*
- EditAnywhere
- Curve attached to timeline to make the transition animation. It must be created on editor and must be of type "FloatCurve" and must have the first key on value "0", and the last one must be on value "1". Timestamps are not important since it's gonna be recalculated on begin play.
Hexagons
- Type: TArray<UTK_Hexagon*>
- EditAnywhere
- Instanced: this allows us to select the class on editor's array automatically, instead of creating it on world outliner and then selecting it manually.
This array have the class hexagon, which is used to store some useful information and all the target points.
- Inner properties
WaitTimeHandle
- Type: FTimerHandle
PositionBetweenPlayers
- Type: FVector
ArrayOfTikis
- Type: TArray<ATK_Player*>
World
- Type: UWorld*
SpringArm
- Type: USpringArmComponent*
SpringArmPosition
- Type: FVector
**SpringArmLength **
- Type: float
- Default: BASE_ARM_LENGTH
ActualHexagon
- Type: UTK_Hexagon*
ActualCameraPoint
- Type: UTK_TargetCameraPoint*
LastCameraPoint
- Type: UTK_TargetCameraPoint*
LastCameraRotation
- Type: FRotator
- Default: FRotator::ZeroRotator
bIsMovingBetweenPoints
- Type: bool
- Default: false
ActualHexagonIndex
- Type: int
- Default: 0
ActualCameraPointIndex
- Type: int
- Default: 0
bIsOutAngleRight
- Type: bool
- Default = false
bIsOutAngleLeft
- Type: bool
- Default: false
TimelineTransition
- Type: UTimelineComponent*
- Base Functionality
DoBasicBehaviour
- Calculate the center point of all tikis and move the camera to that point.
CalculateFOV
- OUT: float: FOV
- Returns the value of the field of view the camera should be using accordingly to the zoom.
SetCameraFOV
- IN: float: NewFOV
- Sets the new value for the field of view.
SetCameraRotation
- IN: FRotator NewCameraRotation
- Sets the new angle for the camera (it actually changes the rotation of the SpringArm, not the Camera itself).
SetCameraArmLenght
- IN: float NewCameraRotation
- Sets the new length for the SpringArm that works out like the zoom in/out.
GetCameraFOV
- OUT: float: FOV
- Gets the actual FOV of the camera.
GetCameraRotation
- OUT: FRotator: CameraRotation
- Gets the actual rotation of the camera.
GetCameraArmLength
- OUT: float : CameraArmLength
- Gets the actual legth of the camera's SpringArm (zoom level).
AlignToTikis
- This function makes the camera to rotate and follow the tikis (center point of all of them).
TransitionBetweenPoints
- This function makes the camera to move from one PropertyPoint to another.
UpdatePositionBetweenPlayers
- Get the position from all tikis and update the variable ("PositionBetweenPlayers") holding the center of them all.
GetDistanceBetweenPlayersAndPoint
- IN: UTK_TargetCameraPoint* TargetPoint
- OUT: float
- Given a TargetPoint, get the distance from that point to the center of the tikis ("PositionBetweenPlayers").
CameraTransitionToCameraPoint
- IN: int NextCameraPointIndex = 0
- Check if the camera should move to another camera point or to another hexagon.
SetCameraPositionAndRotation
- IN: UTK_TargetCameraPoint* Point
- Sets the new camera position and rotation taking a camera point as reference.
ChangeHexagon
- Changes the camera from one hexagon to another, changing the camera point as well.
ChangeCameraPoint
- IN: int NewCameraPointIndex
- Change the actual camera point to the NewCameraPointIndex. No matter the index, this change won't be greater than the actual position + 1 or less than the actual position - 1 to avoid instant transitions frm one point to another too far away.
ZoomInOut
- Changes the SpringArm length depending on the distance between players.
StartMovingBetweenPoints
- Calls the Start function of our timeline.
UpdateTimeline
- IN: float: DeltaTime
- Calls the UpdateCallback function of our timeline.
TimelineCallback
- IN: float: Value
- Set the position and rotation (when needed) of the camera with a lerp.
TimelineFinishedCallback
- Called when finish the timeline.
SetFinishMovingBetweenPoints
- Allows the camera to move again.
SetupTimeline
- This function must be called on BeginPlay to allow the movement from one point to another. It will create our timeline and readjust the FloatCurve keys to match the animation time (TimeTransition) we specified, along with the link to callback and finish functions.
- Utility Functionality
InitTikis
- Initializes our tikis variables to use later.
UpdateIfInsideAngle
- Checks if our current angle of rotation is still inside the boundaries.
IsAtEdgeOfHexagon
- IN: int DirectionToCheck
- OUT: bool
- Checks if the center of the tikis are at the edge of our playable zone and if our rotation match the direction that edge is.