sm.camera

The camera library contains methods related to the localPlayer's camera view.

In first-person view the camera is located inside the player's head, whereas in third-person view it floats behind them.

This library can only be used on the client.

Constants:

Functions:

  • cameraSphereCast
  • getCameraPullback
  • getCameraState
  • getDefaultFov
  • getDefaultPosition
  • getDefaultRotation
  • getDirection
  • getFov
  • getPosition
  • getRight
  • getRotation
  • getUp
  • setCameraPullback
  • setCameraState
  • setDirection
  • setFov
  • setPosition
  • setRotation
  • setShake

  • sm.camera.state table

    Camera states are used to specify how the camera will view the world. The default state is meant for normal gameplay and the first-person and third-person states are meant to be used in cutcenes.

    The states are:

    default 1
    cutsceneFP 2
    cutsceneTP 3

    sm.camera.cameraSphereCast(radius, start, direction)

    Client only

    Performs a distance convex sweep with the shape of a sphere, from a position with a given direction.

    Parameters:

    TypeNameDescription
    numberradiusThe radius of the cast sphere
    Vec3startThe start position.
    Vec3directionThe cast direction and range.

    Returns:

    TypeDescription
    numberThe fraction of the distance reached until collision.

    sm.camera.getCameraPullback()

    Client only

    Returns the camera's zoom step.

    Returns:

    TypeDescription
    numberstep How far away the camera is from the player while standing
    numberstep How far away the camera is from the player while seated

    sm.camera.getCameraState()

    Client only

    Gets the camera's control state.

    Returns:

    TypeDescription
    integerstate How the camera is moved. (See sm.camera.state)

    sm.camera.getDefaultFov()

    Client only

    Returns the camera's default field of view angle.

    Returns:

    TypeDescription
    Vec3The field of view.

    sm.camera.getDefaultPosition()

    Client only

    Returns the world postition where the camera should be by default.

    Returns:

    TypeDescription
    Vec3The camera's world position.

    sm.camera.getDefaultRotation()

    Client only

    Returns the world rotation where the camera should be by default.

    Returns:

    TypeDescription
    QuatThe camera's default world rotation.

    sm.camera.getDirection()

    Client only

    Returns the direction the camera is aiming.

    Returns:

    TypeDescription
    Vec3The direction of the camera's aim.

    sm.camera.getFov()

    Client only

    Returns the camera's field of view angle.

    Returns:

    TypeDescription
    Vec3The field of view.

    sm.camera.getPosition()

    Client only

    Returns the world postition of the camera.

    Returns:

    TypeDescription
    Vec3The camera's world position.

    sm.camera.getRight()

    Client only

    Returns the right-vector perpendicular to the camera's aim.

    Returns:

    TypeDescription
    Vec3The right-vector of the camera's aim.

    sm.camera.getRotation()

    Client only

    Returns the world rotation of the camera.

    Returns:

    TypeDescription
    QuatThe camera's world rotation.

    sm.camera.getUp()

    Client only

    Returns the up-vector perpendicular to the camera's aim.

    Returns:

    TypeDescription
    Vec3The up-vector of the camera's aim.

    sm.camera.setCameraPullback(step, step)

    Client only

    Sets the camera's zoom step.

    Parameters:

    TypeNameDescription
    integerstepHow far away the camera is from the player while standing
    integerstepHow far away the camera is from the player while seated

    sm.camera.setCameraState(state)

    Client only

    Sets the camera's control state.

    Parameters:

    TypeNameDescription
    integerstateHow the camera is moved. (See sm.camera.state)

    sm.camera.setDirection(direction)

    Client only

    Sets the direction the camera is aiming.

    Parameters:

    TypeNameDescription
    Vec3directionThe direction of the camera's aim.

    sm.camera.setFov(FOV)

    Client only

    Sets the camera's field of view angle.

    Parameters:

    TypeNameDescription
    Vec3FOVThe field of view.

    sm.camera.setPosition(position)

    Client only

    Sets the world postition of the camera.

    Parameters:

    TypeNameDescription
    Vec3positionThe camera's world position.

    sm.camera.setRotation(rotation)

    Client only

    Sets the rotation of the camera.

    Parameters:

    TypeNameDescription
    QuatrotationThe rotation of the camera.

    sm.camera.setShake(strength)

    Client only

    Sets the camera's level of camera shake.

    Parameters:

    TypeNameDescription
    numberstrengthThe camera shake strength.