Web3 First Person Shooter - Helping Each Other

Lets use this thread to support each other with questions regarding the Web3 FPS Project :star_struck:

Read instructions: https://moralis.io/moralis-projects-learn-to-build-a-web3-space-fps-game/

Feel free to ask for help here - but also ensure YOU HELP people that are asking questions you know the answers to

The Moralis staff and community managers will be keeping an eye on this too :star_struck:

5 Likes

Unity seems like it came with version 3.33 LTS and when I tried to open up the project file, it threw unity-web3-spaceFPS was created with 2020.3.26f1.

I didn’t see 3.26 in the download options, so I tried to rebuild it with 3.33 and got 999 compilations error when trying to open it.

Here’s a link to download the editor:

In the process of confirming that works:

It keeps failing when I’m trying to install 2020.3.26f1.

1 Like

Hey @mattjaf,

Are you having problems installing Unity 2020.3.26f1 or opening the project with 2020.3.26f1?

1 Like

For everyone trying to run the project on higher versions than 2020.3.26f1 and finding the “Newtonsoft” error, do the following:

  1. Open the manifest.json located in "unity-web3-spaceFPS\Packages"

  2. Add newtonsoft dependency: “com.unity.nuget.newtonsoft-json”: “2.0.0”,
    So the manifest.json will look like this:

  3. Save the file and let Unity recompile. That should fix it :slight_smile:

2 Likes

Hey, there! Great tutorial!
I got it working by following the Youtube Video, but now I’m trying changing everything to Mumbai Test. However I’m getting this NullReferenceException: Object reference not set to an instance of an object error.

Does anyone know how to fix it?

I’ve setup a Moralis Testnet Server with Polygon Mumbai EVM.

And I’ve changed the ChainID on WalletConnect component.

I tried restarting the project to use the original setup with Ethereum Mainnet and the same error is hapenning.

I’ve found out that task.Result is coming as Null in this line.

Are you on the same chain when scanning the qr code ?
and did you set the chain in wallet connect ?

Sup, 0xprof!

Yeah, I’ve set up a Moralis Server with Ethereum Mainet and used its Server URL and App Id on MoralisSetup component.
Then I’ve opened my Metamask app with an account on Ethereum Mainnet and scanned the QR Code.
The WalletConnect has the default ChainID as 1.
I tried using Trust Wallet as well, but the same error happen.

The strangest thing is that it worked the first time I’ve downloaded and configured the project. Then I tried using a Moralist Server with Mumbai Testnet and changed the URL and App Id accordingly. I also changed the WalletConnect ChainID.

The error happened so I tried reverting all changes to the first and initial config, but it stopped working throwing the same error.

I’ve just tried deleting the project’s folder and unzipping it all again, but I’m stuck with the NullReferenceException error.

This is the Dashboard logs:

did you clear the session on the wallet connect gameobject (scroll to the bottom)
and also you can clear it too from MM mobile (metamask) -> check in settings -> experimental

Yeah, I’ve been clearing sessions every time I tried something new.
I tried clearing Metameask cache and I’ve installed Trust Wallet too, which resulted in the same error.
I also noticed the following error in my logs:
Failed to retrieve server time from Moralis Server!
Because serverTimeResponse comes as Null at the following code

Dictionary<string, object> serverTimeResponse = await MoralisInterface.GetClient().Cloud.RunAsync<Dictionary<string, object>>("getServerTime", new Dictionary<string, object>());

The time on my computer and smartphone is correct.
I tried deleting, creating and restarting Moralis Servers, but it didn’t work.

Unity Version: 2020.3.33f1
Moralis Server Version: 0.0.367

@dpradell
I successfully installed the unity editor version 2020.3.33f1

it fails at like 25ish% every time i try to install 2020.3.26f1

I tried to manually add, “com.unity.nuget.newtonsoft-json”: “2.0.0”, to the dependencies and it has an red line error saying “unexpected end of string”.

was I suppose to open the work space in an IDE and run npm install --save [email protected] or something like that.

Hey, guys. I managed to fix my problem!

After a lot of code reading, I’ve found out that pressing “L” in the connect screen will trigger a “Logout” function that do three things

// Disconnect wallet subscription.
await walletConnect.Session.Disconnect();
// CLear out the session so it is re-establish on sign-in.
walletConnect.CLearSession();
// Logout the Moralis User.
await MoralisInterface.LogOutAsync();

The Clear Session on WalletConnect game object just triggers walletConnect.CLearSession();, so it seems that it was not enough to solve my problem.

1 Like

HI, thanks for the tutorial! It seems to me(sorry if I’m wrong, happy to be corrected) that anyone can claim the NFT from outside the game with a simple smart contract interaction. How could we solve this problem and make the claim function available only to the accounts that finished the game?

Hi @andreitoma8, you’re absolutely correct. As I say in the video, this smart contract was already deployed and used just for this sample project. Adding security to it was not the topic of this tutorial but I’ll do a video about that quite soon :slight_smile:

@mattjaf and everyone here. I updated the sample project to 2020.3.33f1 to avoid any more confusion.

If you have that Editor version, please pull from the repo:

Or just download the updated ZIP file:

Thanks for the response @dpradell ! That sounds great, I can’t wait to see the video you’ll make. Happy hacking!

1 Like

Thank you, ill definitely check it out.

1 Like

Hi,

I try to make a nft on opensea and replace the nft in the sample with that so far no luck…
simply changeing the nft data under claim nft controller on the mug wont to the job.

Hi can you look at the repo code linked above to see if you’ve missed anything. What have you done in code when you say replace the nft?

Well the sample is working perfect. When I made a nft that is mintable on opensea and I replaced the 1 in turtorial with the 1 I made it wont work.


Also what adress needs to be in this field i dont get it? I tried the same adress in the laucher and the adress that deployed the contract. Still no luck