Vehicles in network

#1
Hi. I wanted to ask people familiar with networking how is the proper way of networking the vehicle. No matter if it's flying or ground.
I've seen somewhere in cryengine's documentation, that vehicles should have client authority. Am I correct? If so, then WHEN should I delegate it's authority to client? I can move authority to specified client, so it clearly can't be done on the Initialize(). Should I delegate it when player requests entering vehicle? (And vehicles allow to enter/leave them, player will never be in the vehicle since the match starts).

So what's the proper way to resolve it? I've never been into vehicles, especially networking, and I work with blank template. I already know how to delegate authority, so don't bother with that. What I don't know is WHEN.

Second questions is about attaching player to vehicle. Should it be done through normal attachment system, like everything else? Because I can't manage to slave player to the vehicle in multiplayer.
Cryengine tutorial videos on my Youtube channel! Check it out !
https://www.youtube.com/user/MusicForLifePL20

Re: Vehicles in network

#2
just delegate when player request. dont need attachment. just put player in state and parent it to vehicle and keep local transform when player need take control of vehicle. and disable previous control map, enable vehicle control map. also need to change camera. unparent it and disable vehicle map and enable human control map when player request control human.
Last edited by mknmknmknjk on Sat Nov 11, 2017 2:23 am, edited 1 time in total.

Re: Vehicles in network

#5
Delegation of the entity is possible after binding to network . how do you do it? there was flowgraph Delegation of the entity designed for this situation. how do you do it ? post your code snippet. the flowgraph was called set owner?

https://gamedev.amazon.com/forums/quest ... -code.html
http://code.taobao.org/p/CryEngine3_6_3 ... etwork.cpp

and i search some keyword in source code
find some use case.
https://gitlab.com/search?utf8=%E2%9C%9 ... 9dc7372947

VehicleSeat.cpp GivesActorSeatFeatures


https://gitlab.com/Teo-Mirror/CRYENGINE ... Weapon.cpp

CEnvironmentalWeapon::SetOwner

Re: Vehicles in network

#6

Code: Select all

INetChannel *netChannel = gEnv->pGameFramework->GetNetChannel(ENTITY_THAT_HAS_CHANNEL_WHICH_SHOULD_CONTROL->GetNetEntity()->GetChannelId()); gEnv->pNetContext->DelegateAuthority(ENTITY_THAT_WE_WANT_TO_CONTROL->GetId(), netChannel );
This works for newly spawned entity before it gets bound to network. But vehicle I have is spawned on the map on the beginning of the game and bound to network. When I try to delegate it, it doesn't work.
I did some test. I took my other entity, that delegation works for, and I bound it to network before delegation, and IT DOES NOT WORK. It works only before it's bound to network.
Cryengine tutorial videos on my Youtube channel! Check it out !
https://www.youtube.com/user/MusicForLifePL20

Re: Vehicles in network

#10
I looked into EnvironmentalWeapon in GameSDK. And yes. Seems like they really use delegation on the fly. BUT I do it the same way. Exactly the same way. And with 5.4 IT DOES NOT WORK. I delegate authority but aspects and rmis still don't work at all.

Edit:
Okay, I found the issue, AND IT'S DAMN WEIRD! I found the issue though, but I don't see how I can fix it.

I created test class CTestComponent. And I bound it to network and I have 2 aspects - One is Server - > Client, and the second is Client -> Server. Just for test purposes.
Now.. If I take my test component and drop its instance in the Editor, then NO ASPECTS ARE CALLED, no matter what I do! But if I spawn instance of this component on the fly, during the game, when the map is already loaded, then Server->Client aspect is called properly, and I CAN delegate authority even after BindToNetwork, and then obviously Client->Server immidiately gets called too!

So the question is... What is the logic behind entities spawned from the Editor, that makes it unable to run rmi and aspects on those entities? It is done somewhere internally, so maybe someone from Crytek would brighten me, and say what's going on here?

Edit2:

I just found something.. When I dont use BindToNetwork(), but instead of it I use:

Code: Select all

gEnv->pNetContext->BindObject(GetEntityId(), 0, GetNetSerializeAspectMask(), true);

This entity placed in editor IS FIRING aspects properly! The problem is that although this test component is not related to player at all, When I call this line, Player cannot connect to server. I will keep digging.

Edit3:

The problem is solved! I did not test it fully, for crashes etc, but what I do WORKS at least now.

In Initialize() method of the component:

Code: Select all

//this must happen only on server side, otherwise player won't be able to connect to server, because it will crash on client at this point
if (gEnv->bServer)
gEnv->pNetContext->BindObject(GetEntityId(), 0, GetNetSerializeAspectMask(), true);
//you still have to bind it to network on both sides like the old way
m_pEntity->GetNetEntity()->BindToNetwork();
Now I am able to delegate authority at any time for editor placed entities.
Cryengine tutorial videos on my Youtube channel! Check it out !
https://www.youtube.com/user/MusicForLifePL20

Who is online

Users browsing this forum: No registered users and 1 guest

cron