History

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.

rick@ghostpunch.com committed 9 years ago

Commit 8cf60df1 parent 782155e1 file · +14 −1Browse files

Showing the changes to scripts/tutorials/entity_scripts (1 of 1 file). Show all

Unified · Split

scripts/tutorials/entity_scripts/sit.js+14−1
@@ -122,10 +122,21 @@ · 121 unmodified lines
122122
123123 this.rolesToOverride = function() {
124124 return MyAvatar.getAnimationRoles().filter(function(role) {
125− return role === "fly" || role.startsWith("inAir");
125+ return role === "right" || role.startsWith("left");
126126 });
127127 }
128128
129+ // Handler for user changing the avatar model while sitting. There's currently an issue with changing avatar models while override role animations are applied,
130+ // so to avoid that problem, re-apply the role overrides once the model has finished changing.
131+ this.modelURLChangeFinished = function () {
132+ print("Sitter's model has FINISHED changing. Reapply anim role overrides.");
133+ var roles = this.rolesToOverride();
134+ for (i in roles) {
135+ //print("Overriding role animation " + roles[i]);
136+ MyAvatar.overrideRoleAnimation(roles[i], ANIMATION_URL, ANIMATION_FPS, true, ANIMATION_FIRST_FRAME, ANIMATION_LAST_FRAME);
137+ }
138+ }
139+
129140 this.sitDown = function() {
130141 if (this.checkSeatForAvatar()) {
131142 print("Someone is already sitting in that chair.");
@@ -164,12 +175,14 @@ · 32 unmodified lines
164175 return { headType: 0 };
165176 }, ["headType"]);
166177 Script.update.connect(this, this.update);
178+ MyAvatar.onLoadComplete.connect(this, this.modelURLChangeFinished);
167179 }
168180
169181 this.standUp = function() {
170182 print("Standing up (" + this.entityID + ")");
171183 MyAvatar.removeAnimationStateHandler(this.animStateHandlerID);
172184 Script.update.disconnect(this, this.update);
185+ MyAvatar.onLoadComplete.disconnect(this, this.modelURLChangeFinished);
173186
174187 if (MyAvatar.sessionUUID === this.getSeatUser()) {
175188 this.setSeatUser(null);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t