Verse Library verse

01 Standalone

Smoothly positions and tracks a camera behind and above a target actor using linear interpolation.

verse-library/using-fixed-angle-camera-devices-in-fortnite-creative/01-standalone.verse

// We are defining a script that will run on the Camera Device.
// Think of this as the "Brain" of the camera.
IsometricCamera = script():
    // 1. DEFINE THE TARGET
    // This is the "Look-At Target." In Fortnite terms, this is the actor
    // the camera is obsessed with following.
    Target := struct():
        Actor: Actor
        // We need to know where the target is in the world.
        // 'Get Actor Location' is like asking "Where is the Storm Center?"
        // but for a specific player.
        Location: () -> vector

    // 2. DEFINE THE CAMERA MOVEMENT
    // This function moves the camera.
    // 'Lerp' (Linear Interpolation) is like a healing potion.
    // It doesn't jump from 0 HP to 100 HP instantly. It fills the bar smoothly.
    // Here, it smooths the camera movement so it doesn't jitter.
    MoveCamera := func(Camera: Camera, TargetLoc: vector, DeltaTime: float):
        // Calculate where the camera *should* be based on the target.
        // We want the camera to be behind and above the target.
        DesiredPosition := TargetLoc + vector(0, 0, 500) // 500 units up
        DesiredPosition := DesiredPosition + vector(0, -200, 0) // 200 units back

        // Move the camera towards DesiredPosition smoothly.
        // The camera's current position is 'Camera.Get Location'.
        // We blend between current and desired based on time.
        CurrentPos := Camera.Get Location()
        // Simple smoothing: move 10% of the way there every frame.
        // (In a real game, you'd use a proper Lerp function, but this illustrates the concept).

Sign in free to read the full source 🌴

This Verse Library file is members-only. Create a free account to view the complete source and download the .verse file.

Sign in with Discord

Comments

    Sign in to vote, comment, or suggest an edit. Sign in