Skip to content

Commit

Permalink
modify move-to-unoccupied-waypoint="on:connected;delay:3" to not move…
Browse files Browse the repository at this point in the history
… if url includes a hash to spawn on a specific waypoint (#42)
  • Loading branch information
vincentfretin committed Apr 5, 2024
1 parent c814dc0 commit 9490f4d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ After 3s delay on naf connected event:
```

A delay is needed so we have the waypoints isOccupied information from the other participants.
With `on: connected`, if the url includes a hash to spawn on a specific waypoint, then the component doesn't do anything.

or on a plane on click (default):

Expand Down
2 changes: 2 additions & 0 deletions src/components/waypoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,8 @@ AFRAME.registerComponent("move-to-unoccupied-waypoint", {

listenerTrigger() {
this.triggered = true;
// If the component is used with the connected event and the url includes a hash to spawn on a specific waypoint, then don't move.
if (this.data.on === "connected" && window.location.hash !== "") return;
if (this.triggered && this.waypointsReady) {
setTimeout(this.move, this.data.delay * 1000);
}
Expand Down

0 comments on commit 9490f4d

Please sign in to comment.