npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rbx-character-controller

v0.0.15

Published

A character controller for roblox-ts.

Downloads

22

Readme

rbx-character-controller

Example

import { CharacterController, State, Animation } from "rbx-character-controller"
import { UserInputService, Players } from "rbx-services"

const player = Players.LocalPlayer as Player

const states = new Array<typeof State>()

class None extends State {

    static id = "None"

    static init(characterController: CharacterController) {
        
        
        
    }

    static start(characterController: CharacterController) {

        characterController.setVelocity(new Vector3())

    }

    static stop(characterController: CharacterController) {
    }

}
states.push(None)

class Walk extends State {

    static id = "Walk"

    static animation: Animation

    static init(characterController: CharacterController) {

        this.animation = characterController.loadAnimation(180426354)

        characterController.moveInput((moveDirection: Vector3) => {
            
            characterController.move(moveDirection)

            if (moveDirection !== new Vector3(0, 0, 0)) {

                if (characterController.isGrounded()) {

                    if (!this.animation.isPlaying()) {

                        this.animation.play()

                    }

                } else {

                    this.animation.stop()

                }

            } else {

                this.animation.stop()

            }

        })

    }

    static start() {
    }

    static stop() {
    }

}
states.push(Walk)

class Jump extends State {

    static id = "Jump"

    static animation: Animation

    static init(characterController: CharacterController) {

        this.animation = characterController.loadAnimation(125750702)
        
        characterController.jumpInput(() => {
            
            if (characterController.isGrounded()) {

                characterController.setState("Jump")

            }

        })

    }

    static start(characterController: CharacterController) {

        const connection = characterController.landed(() => {

            connection.Disconnect()

            if (characterController.getState() === "Jump") {

                characterController.setState("None")

            }

        })

        characterController.bounce(50)

        Jump.animation.play()

    }

    static stop(characterController: CharacterController) {

        

    }

}
states.push(Jump)

player.CharacterAdded.Connect(character => {
    
    character.PrimaryPart = character.WaitForChild("HumanoidRootPart")
    const characterController = new CharacterController(character)
    characterController.addStates(states)
    characterController.setState("None")

})

Documentation

CharacterController

constructor(character: Model)
// Creates a new CharacterController. Expressed as new CharacterController(character).

getVelocity(): Vector3
// Gets the character velocity.

setVelocity(velocity: Vector3)
// Sets the character velocity.

getMobile(): boolean
// Returns true if the character is mobile.

setMobile(mobile: boolean)
// Sets the mobile state.

bounce(height: number)
// Bounces the character to the specified height

move(direction: Vector3)
// Moves the character in the specified direction.

isGrounded(): boolean
// Returns true if the character is grounded.

isMoving(): boolean
// Returns true if the character is moving

humanoidStateChanged(event: Function): RBXScriptConnection
// Runs event when the humanoid state changes.

landed(event: Function): RBXScriptConnection
// Runs when the character lands.

getPrimaryPart(): BasePart
// Gets the primary part of the character.

getHumanoid(): Humanoid
// Gets the humanoid of the character.

jumpInput(event: Function): RBXScriptConnection
// Runs event when a jump input is pressed (Space, A, Mobile jump button, etc.).

moveInput(event: Function): RBXScriptConnection
// Runs event every frame and passes moveDirection as a param.

crouchInput(event: Function): RBXScriptConnection
// Runs event when a crouch input is pressed (Shift, LT/L2, etc.).

addState(state: typeof State)
// Adds a state to the character.

addStates(states: Array<typeof State>)
// Adds states to the character.

setState(stateName: string)
// Sets the character state.

getState(): State
// Gets the character state.

loadAnimation(animationId: number): Animation
// Loads the specified animation

getAnimatable(): boolean
// Gets the animatable state.

setAnimatable(animatable: boolean)
// Sets the animatable state.

character: Model
// The character model.

State

static id: string
// The id of the state.

static init()
// Called when the state initializes.

static start()
// Called when the state starts.

static stop()
// Called when the state stops.

Animation

play()
// Plays the animation.

stop()
// Stops the animation.

isPlaying()
// Returns true if the animation is playing.