repo: janusweb
action: commit
revision: 
path_from: 
revision_from: c3f19d2654eccf4ac733616ff36cc7b6d3522724:
path_to: 
revision_to: 
git.thebackupbox.net
janusweb
git clone git://git.thebackupbox.net/janusweb
commit c3f19d2654eccf4ac733616ff36cc7b6d3522724
Author: James Baicoianu 
Date:   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
index 73dc9e0b5076e5ce507b05e914b5a6159bd5a41e..
index ..2c0a4ade8bc346631948aab6fb1155a214a8a960 100644
--- 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-----