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