top of page

Urban Nightmare

Contribution

  • Quick Time Event System

    • Two major systems:

      • Collapsing Buildings​

      • Wall Obstacles

Collapsing Buildings​

Wall obstacles

  • Collapsing Buidling

    • Utilizing dot-product to determine whether the player is to the left or right of the building

    • Steps:

      • vector_to_player = player.position - bldg.position​

      • forward_vector_bldg = bldg.forwardvector

      • Take dot product of both vectors above

      • If result > 0, player is to the right

      • If result < 0, player to the left

    • To make the bldg fall, I am simply adding an impulse based on direction.

  • Wall obstacles

    • Utilizing dot-product to determine whether the player is to the left or right of the wall​

    • Once the position of the player is determined, I am changing its position by a number which the designers can tweak within the editor according to their need.

    • I am also determining the velocity of the player when its near the wall. The wall will only shoot itself if the player enter the collision with a certain velocity. This can also be tweaked by the designers.

  • Game Mechanics

    • Two major systems:

      • Checkpoint System

      • Hazardous Gameobjects

Checkpoint System

Harzardous Street Lamps

  • Checkpoint System

    • Utilizing Unreal Engine's game instance

    • A Checkpoint Actor variable in the game instance stores information about the last checkpoint

    • When the player, overlaps with the checkpoint actor, the checkpoint variable in the game instance gets set to the overlapped actor.

    • Everytime the player needs to respawned, the checkpoint variable in the game instance is used as a reference, and the player is spawned at that Checkpoint's world location.

    • The Checkpoint actor has a reference static mesh which helps with the direction that player should face when respawned. Just match the rotation to the reference's rotation.

    • The EDGE CASE:

      • What should happen if the player triggers a checkpoint at an earlier point in the level after having already triggered a checkpoint further ahead in the same level?​

        • Dot Product: Recording the checkpoint info only if the player and the Checkpoint face each other when the overlap happens.​

  • Street lamps hazards

    • Utilizing sine-functions for the pendulum motion of the lamp.

    • The lamp has a hidden child mesh that detects if the player has overlapped.

    • Once the player starts overlapping, I calculate the "Look At Rotation"

      • ​Calculate the direction vector from the start position to the target position 

      • Calculate the yaw rotation (rotation around the up axis) using FMath::Atan2(Direction.Y, Direction.X). This function calculates the angle (in radians) between the positive X-axis and the direction vector projected onto the XY plane.

      • Calculate the pitch rotation (rotation around the right axis) using FMath::Acos(FVector::DotProduct(Direction, Up)). This function calculates the angle (in radians) between the direction vector and the up vector (assumed to be (0, 0, 1)).

      • Negate the pitch rotation if the target position is below the start position (the direction vector has a negative Z component).

      • Create and return a FRotator instance with the calculated pitch, yaw, and roll (set to 0.0f) values

bottom of page