Address #21402 Added a handler to Sit.js script for the onLoadComplete signal to which re-applys the siting animation rol overrides. This works around a bug that shows up if the user switches avatars while the current avatar has overloaded anim roles.

This commit is contained in:
rick@ghostpunch.com 2017-07-11 18:24:19 -04:00
parent 782155e9ea
commit 8cf60df5b0

View file

@ -122,10 +122,21 @@
this.rolesToOverride = function() {
return MyAvatar.getAnimationRoles().filter(function(role) {
return role === "fly" || role.startsWith("inAir");
return role === "right" || role.startsWith("left");
});
}
// Handler for user changing the avatar model while sitting. There's currently an issue with changing avatar models while override role animations are applied,
// so to avoid that problem, re-apply the role overrides once the model has finished changing.
this.modelURLChangeFinished = function () {
print("Sitter's model has FINISHED changing. Reapply anim role overrides.");
var roles = this.rolesToOverride();
for (i in roles) {
//print("Overriding role animation " + roles[i]);
MyAvatar.overrideRoleAnimation(roles[i], ANIMATION_URL, ANIMATION_FPS, true, ANIMATION_FIRST_FRAME, ANIMATION_LAST_FRAME);
}
}
this.sitDown = function() {
if (this.checkSeatForAvatar()) {
print("Someone is already sitting in that chair.");
@ -164,12 +175,14 @@
return { headType: 0 };
}, ["headType"]);
Script.update.connect(this, this.update);
MyAvatar.onLoadComplete.connect(this, this.modelURLChangeFinished);
}
this.standUp = function() {
print("Standing up (" + this.entityID + ")");
MyAvatar.removeAnimationStateHandler(this.animStateHandlerID);
Script.update.disconnect(this, this.update);
MyAvatar.onLoadComplete.disconnect(this, this.modelURLChangeFinished);
if (MyAvatar.sessionUUID === this.getSeatUser()) {
this.setSeatUser(null);