NPCAnimationController
The NPCAnimationController library provides a lightweight method of having NPCs perform animations as their states change.
Variables
Cache: table used to cache animation statesDefaultAnimations: table used for default NPC animations when none is provided
Functions
Jump(Id | string, Active | bool)
Performs a Jump animation when Active is true.
FreeFall(Id | string, MoveDirection | Vector3, WalkToPoint | Vector3, Active | bool)
Performs a FreeFall animation when Active is true and performs landing when Active is false.
Running(Id | string, MoveDirection | Vector3, Speed | number)
Adjusts between Idle, Walk and Run depending on the provided speed.
MoveDirectionChanged(Id | string, MoveDirection | Vector3)
Adjusts between Idle and Walk depending on the MoveDirection.
Climbing(Id | string, Speed | number)
Performs or stops a Climb animation depending on the provided speed.
Seated(Id | string, Active | bool, CanSit | bool, Humanoid | Humanoid)
Performs or stops a Sit animation depending on Active and CanSit.
Setup(Id | string, NPC, Animations | table, CanSit | bool: false, CanSwim | bool: false)
Sets up the NPC to have animations through the NPCAnimationController.
NPCAnimationController:Setup("NPC1", script.Parent)
You can also disable default humanoid states without enabling animations by setting Animations as false:
NPCAnimationController:Setup("NPC1", script.Parent, false)
For custom animations, you can change the animation IDs in the following script:
NPCAnimationController:Setup("NPC1", script.Parent, {
Idle = "rbxassetid://507766388",
Walk = "rbxassetid://507777826",
Run = "rbxassetid://507767714",
Swim = "rbxassetid://507784897",
SwimIdle = "rbxassetid://507785072",
Jump = "rbxassetid://507765000",
Fall = "rbxassetid://507767968",
Climb = "rbxassetid://507765644",
Sit = "rbxassetid://2506281703"
})