repo: janusweb action: commit revision: path_from: revision_from: c3f19d2654eccf4ac733616ff36cc7b6d3522724: path_to: revision_to:
commit c3f19d2654eccf4ac733616ff36cc7b6d3522724 Author: James BaicoianuDate: Sun Jul 25 11:24:37 2021 -0700 Only activate portals on collide if moving towards diff --git a/scripts/portal.js b/scripts/portal.js
--- a/scripts/portal.js
+++ b/scripts/portal.js
@@ -617,8 +617,14 @@ elation.require(['janusweb.janusbase'], function() {
}
}
this.handleCollide = function() {
- this.activate();
- player.vel = V(0,0,0);
+ // Only activate portal if the player is walking towards it
+ let fwd = this.localToWorld(V(0,0,1)).sub(this.localToWorld(V(0,0,0)));
+ let dot = fwd.dot(normalized(player.vel));
+ if (dot < 0) {
+ this.activate();
+ // FIXME - we should be transforming the user's velocity into the new room's coordinate space, but right now a portal isn't aware of what's on the other side
+ //player.vel = V(0,0,0);
+ }
}
}, elation.engine.things.janusbase);
});
-----END OF PAGE-----