Noob Questions about viewing characters and character damage

Post here all your questions related with SmartFoxServer .Net/Unity3D API

Moderators: Lapo, Bax

grfxman
Posts: 7
Joined: 27 Nov 2009, 00:10
Contact:

Noob Questions about viewing characters and character damage

Postby grfxman » 27 Nov 2009, 10:29

I'm trying to figure out how to alter the island demo so the player can see himself from an over the shoulder camera and also how I could incorporate this Unity example :

http://unity3d.com/support/resources/ex ... tomization

Last but not least, What is the best way to handle characters damaging each other with weapons and losing health?

Sorry I'm sure these are basic questions but I'm very new at this. :)
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 27 Nov 2009, 15:37

Hi and welcome :-)

This forum is for the SmartFoxServer API that sits between Unity games and a SmartFoxServer in a networking environment, so the best place to ask more Unity related questions would definitely be http://forum.unity3d.com

They are super friendly there and helpful - and you are naturally more than welcome to ask SFS networking related questions here.

Best
Thomas
grfxman
Posts: 7
Joined: 27 Nov 2009, 00:10
Contact:

Postby grfxman » 27 Nov 2009, 22:02

Well the question are networking based as far as I know. I can get these things to work easily in Unity. My confusion comes with how to get the data to send to other players within SmartFox efficiently.

For example Each Player are going to each have unique meshes and I can code that quite easily in Unity.

But I have no idea what the PROPER method of sending that data to all the players is.

In the island demo You don't have a mesh at all and you view all other players as Lerpz. Should I set up user variables or Room variables to change this etc... Which way is proper and best for a situation where you may have hundreds of players. I'm not sure because I can't find one single example of this to work with.

Thanks for your time :)
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 28 Nov 2009, 09:01

Hi!

Ahh yeah - formulated like that, you are asking SFS questions :-)

First question you need to ask yourself is, if you want authoritative server or not (meaning - server side logic that controls everything including cheat checks etc.etc.).

In the latter case you are going to code a java extension on the server, and then communicate with it using the SendXtMessage methods.

The island demo as it is currently uses SendObject, which is a basic "spam all clients in the same room with me with this object, using server only for message relay".

The above isnt really very efficient once you scale up, but it can work great for some things that neither require server side logic, that every player has to get and/or dont happen that often.

Otherwise its time to break open your Java skills and write extensions.

Onto your questions in more specifics:

As usual there is no "only one way" solution, so what is specific for you might not apply for others.

But in general you need rework how the island demo sends its transforms if you want to scale up. The transform should be packed on the client side, send to a server extension, where its then even further aggregated with everyone elses transform and send out as a single "position update" to all clients. They then need to unpack and apply the transform updates to the avatars. This will save _a lot_ of bandwidth and be an efficiency improvement.

You can then further create zones. If your server knows about your level design, you can create zones and restrict sending update messages to contain only enemy transforms that are actually visible and/or within range. Or you could do it distance based and throttle sending updates.

For changing clothes or avatar model, it somewhat depends on how often this could happen.

You can either use user variables in the existing methods (and would then get an user variable updated callback) - or if someone changes his clothes you can send it out from an extension similar to the above mentioned transform method.

For damage models and health - you are starting to really move into a situation where you need an authoritative server. This is an area of itself to write a book about.

The short version: for anything that your game client wants to do, it sends a request to the server saying "I would like to shoot my gun at player 4. Is that ok?"

The server has your entire game logic and data running as a simulation. It is the ONLY place where the data model lives (hence authoritative). The server could in your example now run the following:

* check if you actually carry the gun you claim
* check if its out of ammo
* check if player 4 is actually in range of you
* run a line of sight check and see if you can see the player
* grab the stats for your weapon out of the data model
* run the "determine if you hit" code
* apply the resulting damage to the data model on the server side
* send back the resulting damage info to all game clients (especially the 2 battling it out)

THEN the clients do what they do with the data they get back.

The above would vary depending on the exact game you make, but this is how e.g. WAR and WoW do it. The game client runs some kind of animation while the server does its things. E..g if you cast a spell, it does some kind of "wave arms around for 2 secs" animation. In this time, the server runs the code and sends back to the clients ASAP. Then the resulting fireball is spawned after time is over, damage info floats over the heads and a monster die animation might be shown. But thats simply rendering the result of that one response/request exchange between client and server.

So that model you apply all over!!

Hope that answers your questions :-D

/Thomas
grfxman
Posts: 7
Joined: 27 Nov 2009, 00:10
Contact:

Postby grfxman » 28 Nov 2009, 23:59

First thanks for the detailed answer Thomas. :)

Just reading through this though, It seems like I have my work cut out for me to change the sample island to an authoritative server.

It seems I need to find 2 basic examples so I can understand this.

-1- First a simple example using basic shapes on a plane doing this:

The transform should be packed on the client side, send to a server extension, where its then even further aggregated with everyone elses transform and send out as a single "position update" to all clients. They then need to unpack and apply the transform updates to the avatars. This will save _a lot_ of bandwidth and be an efficiency improvement.



-2- Second the same example but with the ability to shoot a basic sphere/projectile at the other player and registering where it made a hit.

Then I could build from that. If you know of any good links that would show these 2 cases it would be greatly appreciated. :)

Thanks again for your time.
grfxman
Posts: 7
Joined: 27 Nov 2009, 00:10
Contact:

Postby grfxman » 03 Dec 2009, 20:16

So I keep hearing there is a text file that goes with the Smartfox island demo but I can't find it in the download.

Also you mentioned packing the objects transforms then sending that to the server. Wher would I find an example of that with Unity? Preferably using the raw-protocol.

Thanks :)

Return to “.Net / Unity3D API”

Who is online

Users browsing this forum: No registered users and 16 guests