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
122 122
123 this.rolesToOverride = function() {123 this.rolesToOverride = function() {
124 return MyAvatar.getAnimationRoles().filter(function(role) {124 return MyAvatar.getAnimationRoles().filter(function(role) {
125 return role === "fly" || role.startsWith("inAir");125 return role === "right" || role.startsWith("left");
126 });126 });
127 }127 }
128 128
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
129 this.sitDown = function() {140 this.sitDown = function() {
130 if (this.checkSeatForAvatar()) {141 if (this.checkSeatForAvatar()) {
131 print("Someone is already sitting in that chair.");142 print("Someone is already sitting in that chair.");
@@ -164,12 +175,14 @@ · 32 unmodified lines
164 return { headType: 0 };175 return { headType: 0 };
165 }, ["headType"]);176 }, ["headType"]);
166 Script.update.connect(this, this.update);177 Script.update.connect(this, this.update);
178 MyAvatar.onLoadComplete.connect(this, this.modelURLChangeFinished);
167 }179 }
168 180
169 this.standUp = function() {181 this.standUp = function() {
170 print("Standing up (" + this.entityID + ")");182 print("Standing up (" + this.entityID + ")");
171 MyAvatar.removeAnimationStateHandler(this.animStateHandlerID);183 MyAvatar.removeAnimationStateHandler(this.animStateHandlerID);
172 Script.update.disconnect(this, this.update);184 Script.update.disconnect(this, this.update);
185 MyAvatar.onLoadComplete.disconnect(this, this.modelURLChangeFinished);
173 186
174 if (MyAvatar.sessionUUID === this.getSeatUser()) {187 if (MyAvatar.sessionUUID === this.getSeatUser()) {
175 this.setSeatUser(null);188 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