Skip to content

atl/sm/localplayer

import "atl/sm/localplayer"

The player on this client (sm.localPlayer).

func Player() sm.Player

The local Player object.

func ID() int

The local player's id.

func World() sm.World

The world the local player is in.

func Position() sm.Vec3

The local character's position, or zero when there is no character.

func Direction() sm.Vec3
func Right() sm.Vec3
func Up() sm.Vec3

The look direction and the directions to its right and up.

func SetDirection(d sm.Vec3)

Turns the view to face direction d.

func Raycast(rng float64, origin, direction *sm.Vec3) (physics.RaycastHit, bool)

Raycasts from the player's view up to rng meters; origin and direction default to the view.

func LatestRaycast() (physics.RaycastHit, bool)

The raycast the game made for the player's interaction this frame.

func RaycastStart() sm.Vec3

Where interaction raycasts start.

func ActiveItem() sm.Uuid

The uuid of the item in the selected hotbar slot.

func SelectedHotbarSlot() int

The selected hotbar slot index.

func Inventory() sm.Container
func Hotbar() sm.Container
func Carry() sm.Container

The player's inventory, hotbar and carried-item containers.

func AimSensitivity() float64

The player's aim sensitivity setting.

func IsInFirstPersonView() bool

True in first person view.

func WantsSprint() bool

True while the sprint input is held.

func SetLockedControls(locked bool)

Freezes movement and look input, e.g. while one of your menus is open.

func SetBlockSprinting(block bool)

Prevents sprinting.

func AddRenderable(rend string)
func RemoveRenderable(rend string)

Adds / removes a renderable drawn on the first person view model.

func UpdateFpAnimation(name string, time float64, weight *float64, looping bool)

Plays a first person animation at time with an optional blend weight.

func FpBonePosition(bone string) sm.Vec3

World position of a bone of the first person model.

func FpAnimationInfo(name string) sm.AnimationInfo

Information about a first person animation.

func CarryColor() sm.Color

The color of the carried item.

func OwnedLift() sm.Lift

The lift the local player owns.

func SecondaryInteractBusy() bool

True while the equipped tool uses the secondary interaction (e.g. aiming).

func GarmentName(u sm.Uuid) string
func GarmentUpperCaseTitle(u sm.Uuid) string

A garment's (cosmetic's) name and its upper-case title.

func IsGarmentUnlocked(u sm.Uuid) bool

True if the player has unlocked a garment.

func GrantQuestItem(u sm.Uuid)

Survival only: unlocks a cosmetic.

type MouseDelta struct {
X, Y float64
}

Mouse movement this frame.

func ReadMouseDelta() MouseDelta

Reads this frame's mouse movement.

type Placement struct {
Position sm.Vec3
Rotation sm.Quat
}

A position and rotation.

func ConstructionPlacement() (Placement, bool)

Where the shape being placed would go, or false when the player isn't placing.