-
Notifications
You must be signed in to change notification settings - Fork 0
Universal Controller
liopyu edited this page Jun 4, 2024
·
7 revisions
The Universal Controller in AnimationJS allows you to define custom animations and control their execution based on various conditions and player actions. With the Universal Controller event, scripters can easily add animation controllers to their server scripts, allowing for dynamic animation triggers based on various player actions. This event is very similar to KubeJS' player tick event.
AnimationJS.universalController(event => {})- Description: Used to trigger animations on player tick.
-
Example Usage:
event.startAnimation("animationjs:waving");
-
Parameters:
-
animationName: ResourceLocation - The name of the animation specified in the JSON.
-
- Description: Used to trigger animations on player tick with the option to have animations overlap themselves when played.
-
Example Usage:
event.startAnimation("animationjs:waving", true);
-
Parameters:
-
animationName: ResourceLocation - The name of the animation specified in the JSON. -
canOverlapSelf: Boolean - Whether the animation can overlap itself if it's already playing.
-
- Description: Starts a specified animation for the player with extra parameters.
-
Parameters:
-
animationID: ResourceLocation - The name of the animation to start. -
transitionLength: int - Duration of the transition length in milliseconds. -
easeID: String - ID of the easing function to use for animation easing from thedev.kosmx.playerAnim.core.util.Easeclass. -
firstPersonEnabled: boolean - Whether the animation should be visible in first-person view. -
important: boolean - Whether the animation is important and should override other animations.
-
-
Example:
event.startAnimation("animationjs:walk", 3, "LINEAR", true, false);
- Description: Used to play animations on player tick with customizable animation data.
-
Example Usage:
event.startAnimation("animationjs:smith", 1, "linear", true, false, ["playeranimatorapi:headposboundcamera"], parts => { parts.leftArm.setEnabled(false); });
-
Parameters:
-
animationID: ResourceLocation - The name of the animation specified in the JSON. -
transitionLength: int - Duration of the transition length in milliseconds. -
easeID: String - ID of the easing function to use for animation easing. All types can be found here - https://easings.net/ -
firstPersonEnabled: boolean - Whether the animation should be visible in first-person view. -
important: boolean - Whether the animation is important and should override other animations. -
modifiers: List - List of modifiers to apply to the animation. -
partsConsumer: Consumer - Consumer to modify player parts such as part visibility, rotation, etc.
-
- Description: Stops a specified animation for the player.
-
Parameters:
-
animationID: ResourceLocation - The name of the animation to stop.
-
-
Example:
event.stopAnimation("animationjs:walk");
AnimationJS.universalController(event => {
if (!event.player.sprinting) {
event.stopAnimation("animationjs:aggression");
}
if (event.player.sprinting) {
if (event.player.swingTime > 0) {
return event.startAnimation("animationjs:aggression", 3, "LINEAR", true, true);
}
return event.startAnimation("animationjs:sprint", 3, "LINEAR", true, false);
} else if (event.player.isMoving() && event.player.swingTime <= 0) {
return event.startAnimation("animationjs:walk", 3, "LINEAR", true, false);
}
if (event.player.swingTime > 0) return event.startAnimation("animationjs:attack", 3, "LINEAR", true, true);
event.startAnimation("animationjs:idle", 3, "LINEAR", true, false);
});This script demonstrates how to use the Universal Controller to trigger animations based on player actions, such as sprinting, walking, and attacking. Adjust the conditions and animations as needed to customize the behavior according to your preferences.