if equipped entity vanishes, reset grab state

This commit is contained in:
Seth Alves 2016-02-26 10:27:34 -08:00
parent 6c9cf386a6
commit 5594f1e4e5

View file

@ -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.