From 5594f1e4e586fbc3967c1ce13526915cfcc457cd Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Fri, 26 Feb 2016 10:27:34 -0800 Subject: [PATCH] if equipped entity vanishes, reset grab state --- examples/controllers/handControllerGrab.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/examples/controllers/handControllerGrab.js b/examples/controllers/handControllerGrab.js index 9eac023ac4..45d27cbbb9 100644 --- a/examples/controllers/handControllerGrab.js +++ b/examples/controllers/handControllerGrab.js @@ -1446,6 +1446,13 @@ function MyController(hand) { this.heartBeat(this.grabbedEntity); var props = Entities.getEntityProperties(this.grabbedEntity, ["localPosition", "parentID", "position"]); + if (!props.position) { + // server may have reset, taking our equipped entity with it. move back to "off" stte + this.setState(STATE_RELEASE); + this.callEntityMethodOnGrabbed("releaseGrab"); + return; + } + if (props.parentID == MyAvatar.sessionUUID && Vec3.length(props.localPosition) > NEAR_PICK_MAX_DISTANCE * 2.0) { // for whatever reason, the held/equipped entity has been pulled away. ungrab or unequip.