I am trying to automate the process of creating my game. I have a website where people can log in and submit their pictures. Would it be possible in playcanvas, to link to those pictures and replace the pictures in-game accordingly? The tricky thing is I need to have different games for each user. Say User A submitted his pictures, he should have his own game with his own pictures in it. User B submitted his pictures and he should have his own game with his own pictures in it as well. Is this something possible right now with playcanvas?
If by difference you mean that each user will see a different set of images, then yes it is possible. Since you control how the images are stored in your database, you need to add some field property to categorize the image. Then the client will request an image by its category id, instead of direct URL, and the server will find the mapped image and serve it. This way all clients can request the same image, for example, “Wall North”, but the server will send different images, based on other criterias, like the user id stored in the request session, or what have you.
hmm interesting I see what you mean. However, what I want is different “links” for each client. So client “A” will receive a link like www.playcan.vas/htbh and client B will receive a link like www.playcan.vas/sdawdq.
The purpose so that they can shareto their friends and family, and when their friends and family open the corresponding links, it will show the correct pictures.
This is not a correct approach. Think of it as a Facebook application you download from the AppStore. Facebook creates a single app that is downloaded by many users, and each will have their own content inside the app. It’s the same paradigm here - you are not creating a web server with different pages, you are creating a single app with varied content.
So in order for the clients to see different pictures, they would have to make an account in the game, and sign in to that account, which I can then connect their unique ID to my database and select the corresponding picture?
That’s a bit beyond what we can we go into in a forum.
The easiest thing to do would be for your website to generate a long string that would be passed to the PlayCanvas app via URL Param and that would be used as an ‘API token’ to communicate with your database.
This can be dangerous as anyone with the token has access to the whole users account of images.
Does the user have to do anything in the game to set it up or is it purely something that is meant to be played.
If so, you can instead make a copy of the images used in the game somewhere that the PlayCanvas uses via a token. That way, the token cannot be used to access the users data directly and the user can also delete older ‘builds’.
It is fine for anyone to have access to the whole users account of images, since the user would want everyone to look at his images if he decided to post that images on our website. So I think I will go with the easiest option using URL Param. Is there any documentation in playcanvas that can help me with learning how to apply this method?
For communicating with my database and setting up this URL Param, is there any resource that you would recommend me to look at? Sorry I don’t have a very strong foundation in web network and communication
You would have to develop an API endpoint on your server that would take the token and respond with the necessary data that you need. Eg a JSON with key pairs that map the image URLs to some ID used in the PlayCanvas app.