In NetworkCharacterController (Fusion's sample code) why is Velocity and IsGrounded Networked?
The whole answer can be found below.
Try Our
Documentation
Please check if you can find an answer in our extensive documentation on Fusion.
Join Us
on Discord
Meet and talk to our staff and the entire Photon-Community via Discord.
Read More on
Stack Overflow
Find more information on Stack Overflow (for Circle members only).
In NetworkCharacterController (Fusion's sample code) why is Velocity and IsGrounded Networked?
ueharajohji
2022-10-07 11:52:07
I am trying to learn photon fusion through the sample codes. I am just wondering why is there a need for IsGrounded and Velocity to be networked when the transform is already sent across the other players? Does it have something to do with client predictions and stuff?
Comments
Correct, the main reason typically for Networked values is for correct tick accuracy on clients and for client prediction.
Typically values are networked because they are considered "State", which for client prediction is important because these values need to correctly "rewind" during client reconciliation. The client needs to know when it is rewound what the exact server state was for that tick.
ueharajohji
2022-10-08 16:36:01
@emotitron Thanks for the clarification.
I am still reading tons of sample code and I think I am getting the grasps of networked variables.
I still haven't been able to wrap my head around this line
In my understanding the only variable that is affected by the networked "Velocity" is the horizontalVel which gets the x and y of the Velocity. The other variable that is going to change is direction which is controlled via **networkInputData.**Which i suspect can give a bug when a player is moving through stairs (or any uneven surface) with the code below.
Velocity = (transform.position - previousPos) * Runner.Simulation.Config.TickRate;
say for example a player is trying to walk into stairs which has a height that is too high for a player to walk into but walking into the edge of it is possible. this scenario might give the following result
Velocity = (1, 1.5, 1) - (1, 1.34, 1) * Runner.Simulation.Config.TickRate;
= (0, 9.6, 0)
which in this will make a player jump very high (this actually happens in fusion sample code, so I am just wondering if I am missing something or not).
I am not personally familiar enough with NCCP to comment, but someone else may who knows more about that implementation may chime in.
ueharajohji
2022-10-09 03:50:20
@emotitron Okay ! Thanks for sharing your thoughts!
ueharajohji 2022-10-08T16:36:01+00:00
@emotitron Thanks for the clarification.
I am still reading tons of sample code and I think I am getting the grasps of networked variables.
I still haven't been able to wrap my head around this line
horizontalVel = Vector3.ClampMagnitude(horizontalVel + direction * acceleration * deltaTime, maxSpeed);In my understanding the only variable that is affected by the networked "Velocity" is the horizontalVel which gets the x and y of the Velocity. The other variable that is going to change is direction which is controlled via networkInputData. Which i suspect can give a bug when a player is moving through stairs (or any uneven surface) with the code below.
Velocity = (transform.position - previousPos) * Runner.Simulation.Config.TickRate;
say for example a player is trying to walk into stairs which has a height that is too high for a player to walk into but walking into the edge of it is possible. this scenario might give the following result
Velocity = (1, 1.5, 1) - (1, 1.34, 1) * Runner.Simulation.Config.TickRate;
= (0, 9.6, 0)
which in this will make a player jump very high (this actually happens in fusion sample code, so I am just wondering if I am missing something or not).
Is there a solution to this? Because this happens to me all the time, the player bumps into something and goes flying into the air.
Back to top