Showing the changes to scripts/tutorials/entity_scripts (1 of 1 file). Show all
Unified · Split
| @@ -122,10 +122,21 @@ · 121 unmodified lines | ||
| 122 | 122 | |
| 123 | 123 | this.rolesToOverride = function() { |
| 124 | 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 | 140 | this.sitDown = function() { |
| 130 | 141 | if (this.checkSeatForAvatar()) { |
| 131 | 142 | print("Someone is already sitting in that chair."); |
| @@ -164,12 +175,14 @@ · 32 unmodified lines | ||
| 164 | 175 | return { headType: 0 }; |
| 165 | 176 | }, ["headType"]); |
| 166 | 177 | Script.update.connect(this, this.update); |
| 178 | + MyAvatar.onLoadComplete.connect(this, this.modelURLChangeFinished); | |
| 167 | 179 | } |
| 168 | 180 | |
| 169 | 181 | this.standUp = function() { |
| 170 | 182 | print("Standing up (" + this.entityID + ")"); |
| 171 | 183 | MyAvatar.removeAnimationStateHandler(this.animStateHandlerID); |
| 172 | 184 | Script.update.disconnect(this, this.update); |
| 185 | + MyAvatar.onLoadComplete.disconnect(this, this.modelURLChangeFinished); | |
| 173 | 186 | |
| 174 | 187 | if (MyAvatar.sessionUUID === this.getSeatUser()) { |
| 175 | 188 | this.setSeatUser(null); |