@MostHated
Ah. You could try taking out the gravity in extrapolation. Line 915ish of SmoothSync. Comment out everything in between the // Gravity and the // Drag.
I will give that a try. So strange that it worked just fine for the video but then next time I started it, it didn’t. I will be sure to try some more stuff once I finish all my work-related things.
I wonder if this has something to do with it. I was using HLAPI Pro replacement DLL’s for Unity, I was using only the 2017.3 “Fix” version not the “Fix and Improvement” one, but it turns out the dev just told me that the fix version has the below built in it… I would venture to guess that, that is what was causing the funkyness. Though, I am not 100% sure, since I was not using the Unity Network Transform component, unless of course your is tying into it in anyway, if it is, and things are different within it from the normal one, that could account for it acting weird. It says it would require no code changes though, which is why I am wondering if it matters or not.
[2017-08-05] NetworkTransform reimplemented from scratch
-
Problem: NetworkTransform was bloated with lots of components, all together 2144 lines of code. No interpolation. No NavMeshAgent consideration. High and Low compression modes did the same. No distinction between Kinematic and nonKinematic Rigidbodies. Too many computations.
-
Solution: reimplemented it from scratch. 300 lines of clean and simple code. Transform/Rigidbody2D/Rigidbody3D/NavMeshAgent support (including Kinematic Rigidbodies). Interpolation. 4 compression modes, able to squeeze a Rotation into 2 bytes and still work. Teleport detection. Great Gizmo makes it easy to debug.
-
@MostHated
I’m not using NetworkTransform at all in SmoothSync. Switching out the networking dlls does sound kind of scary though.
Hi,
How can I use this asset with an authoritative server? From what I understand, mobile players, can easily increase their cpu tick rate and make a speed hack out of this.
I feel like I am missing an important part here.
Thanks.
@Alkanov
You would use it just like you would with Unity’s NetworkTransform except instead of adding NetworkTransform to your object, you add SmoothSync. Make an authoritative server and spawn the objects as normal. Unchecking LocalPlayerAuthority on Unity’s NetworkIdentity on the object will make the object owned by the server.
Right, but doesnt this means that there is still a lot to do for the client movement to feel quicky responsive? Otherwise clients will have to wait for RTT to see their movement.
Please correct me if I’m wrong.
@Alkanov
Correct. We do not do any kind of player prediction.
That, unfortunately, didn’t do anything to help. I think I am just done messing around with it. Using the rewritten one from HLAPI Pro works just fine, so I will probably just stick with that for now. I appreciate the help though. If I keep messing with this anymore I am going to end up just throwing my computer out the window and deleting my project.
Right. Are you planning to work on this? You would potentially be the only one in the asset store offering such thing. I would pay up to 50 bucks just for that module
Maybe release it as an add-on to this one?
From what I understand, client side prediction for rigidbodies is a terribly difficult problem to solve in Unity currently. Since the vast majority of character controllers use rigidbodies, they are thus stuck with this same challenge.
@Alkanov
I have no plans to work on any client side prediction. I think about it every now and then but nothing is planned.
We all know you want to do it :), so why not?
Also, you could start with just simple client/server movement sync, leave physics aside. I tell you this because I am developing a 2d top down game and it doesn’t involve physics at all (maybe just collision against walls and simple stuff) so i’m sure that many here would use this asset.
With as little as allowing the client to move his own object + sending controller commands to server + moving object in server + some sort of reconciliation in case of lag (if pos in server is too different) it would suffice.
I feel like non-rigidbody use cases are too rare for it to be worth it for Fuestrine’s asset. I would anticipate customers being under the false impression that his client side prediction would/should work for rigidbody controllers, then be disappointed/angry when that impression is corrected. Unjustified bad reviews would follow, etc etc.
Perhaps after this little gem happens, client side prediction will be easier: Calling the physics simulation from C# page-3#post-3422818
Asset works correctly only on authoritative server?
I need sync ball in p2p, ignore who is server.
- Have ball with “Local Player Authority” flag;
- Assign authority for local player;
Code below in ball gameObject:
if (player.isLocalPlayer) // player - link to local player gameObject
{
if (Input.GetKeyUp(KeyCode.T))
Trow(Random.Range(100, 300));
}
//isLocalPlayer only
void Trow(int _force)
{
// Player and ball have different positions and i need to sync start positions and addforce in one frame
// in original code ball visibility hide and show fake object in child of player on all clients to save bandwidth
var timestamp = NetworkTransport.GetNetworkTimestamp();
smoothSync.teleport(timestamp, fake.transform.position, fake.transform.rotation);
var f = userRigidbody.rotation * throwForce * _force;
r.AddForce(f);
CmdForce(timestamp, fake.transform.position, fake.transform.rotation, f);
}
[Command]
void CmdForce (int _timestamp, Vector3 _pos, Quaternion _rot, Vector3 _f)
{
smoothSync.teleport(_timestamp, _pos, _rot);
r.AddForce(_f, forceMode);
RpcTeleport(_timestamp, _pos, _rot, _f);
}
[ClientRpc]
void RpcTeleport(int _timestamp, Vector3 _pos, Quaternion _rot, Vector3 _f)
{
if (hasAuthority) return;
smoothSync.teleport(_timestamp, _pos, _rot);
r.AddForce(_f, forceMode);
}
In this implementation, I need to start the teleport and AddForce 3 times:
- for local client
- for the server
- for other customers
This can cause visual bugs when the network is delayed.
How to do it correctly?
@Alkanov
I do but I certainly wouldn’t be waiting on me for it.
@pan4ezzz
It looks like you are trying to add force to the same object on both the owner and non-owner. You will only want to affect the movement on the owner which will then automatically make it look the same on all non-owners. Let me know if I misunderstood your problem.
Yes exactly!
I have to imitate add force in all instances because the code below does not work
if (player.isLocalPlayer) // player - link to local player gameObject
{
if (Input.GetKeyUp(KeyCode.T))
Trow(Random.Range(100, 300));
}
//isLocalPlayer only
void Trow(int _force)
{
// Player and ball have different positions and i need to sync start positions and addforce in one frame
// in original code ball visibility hide and show fake object in child of player on all clients to save bandwidth
var timestamp = NetworkTransport.GetNetworkTimestamp();
smoothSync.teleport(timestamp, fake.transform.position, fake.transform.rotation);
var f = userRigidbody.rotation * throwForce * _force;
r.AddForce(f);
}
@pan4ezzz
What doesn’t work about it? Nothing is happening at all? It’s not smooth on the non-owners? It only moves on the owner but not the non-owners?
nothing, addforce from isLocalPlayer with hasAuthority does not work for anyone and for himself
@pan4ezzz
It sounds like you are having ownership issues. Does it work if you switch out the SmoothSync.cs with Unity’s Network Transform?