External hyperlinks links to scenes

Hi,

Is there any way to make an external hyperlink to a scene? eg I have a game with multiple scenes. I create a link in my webpage that opens the game at one of those scenes, rather than the default start scene. I’m thinking I could do it by having a login and checkpoints but it would be handy to be able to just direct users to a specific scene, via an external link.

Not out of the box, because you cannot pass a URL thread to the game itself. The HTML page is just a holder for the game code, the game code is rendered by Pixi.JS and doesn’t listen for anything from the HTML page as far as I know.

You might be able to add some kind of listener via Javascript, but I can’t find anything that would indicate it will look at the referrer URL or anything.

Thank you. I suspected it wasn’t possible, but I wanted to put it out there just in case!

runtimeScene.getVariables().get("targetScene").setString(window.location.hash.substring(1));
http://exemple.com/#scene2
http://exemple.com/#scene3

Ok - thank you! I will give this a go! I did a bit of a hack experiment this morning. Using the URLTools extension, I set a condition to change the scene based on the game URL, then made multiple index.html files in the game folder and named them scene1.html, scene2.html etc, and then the link goes to scene1.html and the scene changes. Yours looks like a proper solution though :slight_smile: thank you again.

Hello, I am pretty new to this but I wanted to acheive something similar to this. Is there a way to make it so I can send a custom link that my game generates that a player can send their friend. Then if their friend clicks on the link it automatically open the app with a certain scene. If possible I would also like to store a variable with data based off the link they opened. Is this possible?

I think you might be able to achieve something similar to this using something like Google Firestore (or another database). It wouldn’t use a URL but an in-game code. Generate a random code and store it in a variable along with the recipient’s username/uniqueID. Then, write that variable to Firestore along with the associated scene. The recipient could paste the code into their game (not a URL but an in-game code), which looks up that document in Firestore and triggers the scene based on the associated scene stored in Firestore. I haven’t explained that very well, but does it make sense?

runtimeScene.getVariables().get("targetScene").setString(window.location.hash.substring(0,1));
runtimeScene.getGame().getVariables().get("inviteCode").setString(window.location.hash.substring(1));
1 Like

Awesome! So useful to know JavaScript!

Yes it made sense, I got it working perfectly… now im trying to set up notifications that can be triggered by one person and sent to another. Basically like when someone texts you on an app you get that notification. This is offtopic for this thread but if you had any suggestions on how to do that i would love to hear it. Ive tried using the onesignal extension but can’t quite get it to work… and even if I could, I wouldnt understand how to actually send a notification in the way I want.

Thank you for the reply! I got it working now.