Merge pull request #11467 from sethalves/fix-near-trigger

Fix near trigger
This commit is contained in:
Seth Alves 2017-09-26 17:27:05 -07:00 committed by GitHub
commit f384cde471

View file

@ -26,6 +26,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
this.previousParentID = {};
this.previousParentJointIndex = {};
this.previouslyUnhooked = {};
this.startSent = false;
this.parameters = makeDispatcherModuleParameters(
520,
@ -76,7 +77,6 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
var targetProps = this.getTargetProps(controllerData);
if (targetProps) {
this.targetEntityID = targetProps.id;
this.startNearTrigger(controllerData);
return makeRunningValues(true, [this.targetEntityID], []);
} else {
return makeRunningValues(false, [], []);
@ -84,12 +84,16 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
};
this.run = function (controllerData) {
if (controllerData.triggerClicks[this.hand] === 0) {
if (!this.startSent) {
this.startNearTrigger(controllerData);
this.startSent = true;
} else if (controllerData.triggerValues[this.hand] < TRIGGER_OFF_VALUE) {
this.endNearTrigger(controllerData);
this.startSent = false;
return makeRunningValues(false, [], []);
} else {
this.continueNearTrigger(controllerData);
}
this.continueNearTrigger(controllerData);
return makeRunningValues(true, [this.targetEntityID], []);
};