FPS Example Question

Post here your questions about the Unity / .Net / Mono / Windows 8 / Windows Phone 8 API for SFS2X

Moderators: Lapo, Bax

Sfulk
Posts: 54
Joined: 06 Jul 2012, 17:02

FPS Example Question

Postby Sfulk » 02 Jan 2016, 02:34

I started messing around with unity and figured I'd try out the FPS example. My problem/question is that I like to put things I'm working on on a public sfs2x instance so that i can have friends jump on to try or test something. I found in the lobby folder a script called LoginController.cs which contains the ip/port of server. I changed the ip address from localhost to my public server but the client will only connect to localhost. I don't understand why this is happening. I tried rebuilding and reimporting everything but nothing works. Is this a bug or is there something you have to do when updating a script? Any help would be great.

Thanks,
Scott

Edit: I'm using Unity 5.1.2f1 Personal.
User avatar
Lapo
Site Admin
Posts: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: FPS Example Question

Postby Lapo » 02 Jan 2016, 11:18

Hi,
as far as I can remember those settings must be set from the Unity Editor and not from the code. The reason being that those values are exposed in the Editor's UI they always override those written in the code.

cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
Sfulk
Posts: 54
Joined: 06 Jul 2012, 17:02

Re: FPS Example Question

Postby Sfulk » 02 Jan 2016, 17:34

Hey Lapo,

I’m a little confused when you say the IP must be changed within the Unity Editor. The only place I can find the server IP is in the LoginController.cs. I looked SFS2x example documentation and the developers documentation I noticed that it says:

IMPORTANT
Please note that the walk-through document linked above refers to a slightly different version of the game, still featuring the Unity's legacy GUI system for the Login and Lobby scenes. For this reason some of the screenshots in the document will differ from what you see when loading the project in the Unity Editor. In fact the example has been updated to support the new UI system introduced in Unity 4.6. Please refer to the Tris game tutorial for a description of the Login and Lobby scenes.


In the developer documentation it looks like the host IP is entered during login by the user. In the FPS example I have it only asks for the user’s name and whether they want to invert Y. Is this what you meant by it must be changed in the UI? Sorry for the confusion I haven't got much experience with unity yet.

Thanks,
Scott


Edit: I just found the Login Controller configuration within unity. Now that I see what you were talking about what is the point of adding the ip address in the code in the first place? Also can unity use an external sfs-config file like you would use with flash?

Thanks for your help
User avatar
Lapo
Site Admin
Posts: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: FPS Example Question

Postby Lapo » 04 Jan 2016, 08:25

Hi,
Sfulk wrote:Edit: I just found the Login Controller configuration within unity. Now that I see what you were talking about what is the point of adding the ip address in the code in the first place?

The point is that those public variables need to be initialized to a default value so that, if you don't change them, they will work anyway.

In other words any public variable defined in Unity code will show up in the Editor's inspector:
http://docs.unity3d.com/412/Documentati ... ables.html

Also can unity use an external sfs-config file like you would use with flash?

Yes, it works in the same way, by calling SmartFox.LoadConfig().
If you use that make sure to not use the UI system otherwise it will override the loaded settings.

Hope it helps
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X C# API”

Who is online

Users browsing this forum: Baidu [Spider] and 49 guests