Fix entity stay highlighted after hand leaves when far grabbing another

This commit is contained in:
David Rowe 2018-08-07 15:34:17 +12:00
parent 7dd80d0180
commit c9c23b8db3

View file

@ -100,6 +100,7 @@ Script.include("/~/system/libraries/controllers.js");
this.startNearParentingGrabEntity = function (controllerData, targetProps) {
Controller.triggerHapticPulse(HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, this.hand);
unhighlightTargetEntity(this.targetEntityID);
this.highlightedEntity = null;
var message = {
hand: this.hand,
entityID: this.targetEntityID
@ -177,6 +178,7 @@ Script.include("/~/system/libraries/controllers.js");
joint: this.hand === RIGHT_HAND ? "RightHand" : "LeftHand"
}));
unhighlightTargetEntity(this.targetEntityID);
this.highlightedEntity = null;
this.grabbing = false;
this.targetEntityID = null;
this.robbed = false;
@ -304,6 +306,10 @@ Script.include("/~/system/libraries/controllers.js");
return makeRunningValues(true, [this.targetEntityID], []);
}
} else {
if (this.highlightedEntity) {
unhighlightTargetEntity(this.highlightedEntity);
this.highlightedEntity = null;
}
this.hapticTargetID = null;
this.robbed = false;
return makeRunningValues(false, [], []);
@ -322,6 +328,7 @@ Script.include("/~/system/libraries/controllers.js");
if (!props) {
// entity was deleted
unhighlightTargetEntity(this.targetEntityID);
this.highlightedEntity = NULL;
this.grabbing = false;
this.targetEntityID = null;
this.hapticTargetID = null;
@ -344,6 +351,7 @@ Script.include("/~/system/libraries/controllers.js");
if (!readiness.active) {
this.robbed = false;
unhighlightTargetEntity(this.highlightedEntity);
this.highlightedEntity = null;
return readiness;
}
if (controllerData.triggerClicks[this.hand] || controllerData.secondaryValues[this.hand] > BUMPER_ON_VALUE) {