transport.SetRelayServerData missing argument

In the HostGameManager.cs on line 46 we create a RelayServerData variable that should have everything, but the next line, transport.SetRelayServerData(relayServerData) gives me this error:
“There is no argument given that corresponds to the required parameter ‘port’ […]”

I’m hardstuck here

There are two overloads for SetRelayServerData - it appears you have something wrong and Unity is assuming you are using the wrong one. Make sure you are passing everything correctly. Else, paste it here and we can look at it together

It’s an exact copy paste of the code in the video, but here it is

UnityTransport transport = NetworkManager.Singleton.GetComponent<UnityTransport>();
RelayServerData relayServerData = new RelayServerData(allocation, "udp");

Interesting. I copied your code into my project and I don’t get the error. Perhaps reimport your scripts. You can just go to the Host folder, right-click somewhere in it, and select Reimport. It will force Unity to rebuild the scripts. If that doesn’t work, go to Edit > Preferences… and choose ‘Regenerate Project Files’ under the ‘External Tools’ section

1 Like

I’ve done both, the problem is still there.
You mentioned there’s two overloads for the SetRelayServerData function, but checking it with Visual Studio, I only have one.

I have 2; one that takes the RelayServerData and one that takes a bunch of individual parameters - incuding the port.

I checked the video and Nathan’s also have 2 overloads

Which versions of NGO and Relay are you using?

Okay, so I figured it out. Thanks bixarrio for pointing out there’s two overloads, I wouldn’t have checked otherwise :smiley:

I started suspecting I’m using a different version of some package, so I went back to the third video where we set up the project.
My Unity Packet Manager installed the 1.0.2 version of Netcode For Gameobjects. Even in the video, Nathan installed 1.2.0
So anyways, my Packet Manager was hardstuck on believing 1.0.2 was the latest version of this package. I had to uninstall it, then reinstall Unity to finally get the latest version (1.5.0 as of writing).

Thanks again!

Yeah, I suspected as much. I was using 1.5.0, too.

Enjoy the rest of the course

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms