#CSP pooled respawn

11 messages · Page 1 of 1 (latest)

mellow escarp
#

4.6.12 pro
I'm trying to use practices from FPSLand on FishNet V4 project

As I understand, CSP code changed drastically. So, how to respawn player\teleport it on V4?

Currently I'm setting nob.position on server and send command to client to make it visible. However, client will not teleport to a new position until they try to move. Even more, they will blink at their last\default position on the server side before reconciling to server position.

And is there anywhere FPS CSP on CC for FishNet V4 available to look at? I've looked at a lot of tutorials, FishNet docs, FPS Land - everything is slightly off. FPS land is basically obsolete and all of the tutorials I've seen either just totally unusable for fast-paced FPS scenario, or just implement simplest bare minimum without actually fixing general problems.

quiet tangle
#

Hey there, you should be able to do something similar to this for character controller teleportation from the server.

[TargetRpc(RunLocally = true)]
public void TargetTeleport(NetworkConnection target, Vector3 position)
{
    _characterController.enabled = false;
    transform.position = position;
    _characterController.enabled = true;
    ClearReplicateCache();
}
mellow escarp
#

I've implemented your code and it almost fixed everything, except NetworkTickSmoother still makes other player's character blink. It requires few frames to snap back to 0.

I've tried

GetComponentInChildren<NetworkTickSmoother>().OnStopClient();
GetComponentInChildren<NetworkTickSmoother>().OnStartClient();

but it didn't help

quiet tangle
mellow escarp
#

Yeah, i've attached you a screenshot and a video with debugging. EnableTeleport is ticked on spectator side

quiet tangle
#

Oh gotcha, if you disable the tick smoother entirely does it happen still?

mellow escarp
#

For some reason with Smoother it happens on every respawn and without - only on first ever spawn, then it stops

quiet tangle
#

Hmm, most peculiar. How about if there was no TickSmoother but instead the NetworkObject's Graphical Object field was used?

mellow escarp
#

I don't see any difference

#

Something changes position of transform before rendering happens in the same frame as I've explicitly set position

private Vector3? expectedPosition = null;
private int expectedPositionFrame;

private void OnRespawn(Vector3 position)
{
    _characterController.enabled = false;

    transform.position = position;
    _characterController.enabled = true;
    
    Physics.SyncTransforms();
    
    ClearReplicateCache();

    expectedPosition = position;
    expectedPositionFrame = Time.frameCount;
}

private void LateUpdate()
{
    if (expectedPosition.HasValue)
    {
        Debug.Log($"expected: {expectedPosition.Value} @ {expectedPositionFrame}");
        Debug.Log($"actual: {transform.position} @ {Time.frameCount}");
        expectedPosition = null;
    }
}
mellow escarp
#

Maybe it is a reconcile?

[Reconcile]
private void Reconcile(ReconcileData rd, Channel channel = Channel.Unreliable)
{
    if (Comparers.IsDefault(rd))
        return;

    _verticalVelocity = rd.VerticalVelocity;
    transform.position = rd.Position;
    _isGrounded = rd.IsGrounded;

    if (expectedPosition.HasValue)
    {
        Debug.Log($"reconciled before rendering! set position to {rd.Position}");
    }
}