Problem with position being interpolated when instantiating new object

I'm instantiating a new object with BoltNetwork.Instantiate passing a start position but on the clients the object starts first at the (0, 0, 0) and then interpolates to the correct position.

I'm trying to detect when a client still didn't get its position updated over the network to prevent it from being rendered in the wrong position but I really can't figure it out how to do it.

I tried setting a lower value on the Teleport Threshold so it would instant teleport to its location but this doesn't seem to prevent the model from blinking around on some intermediate position right when I instantiate it.

I also tried setting its initial position on Awake to something really far from the gameplay field so when the position would get updated over the network it would kinda try to force a teleport, no lucky with this, still can see the model blinking in some interpolated position before it gets to where it should be.

Is there a way to know when the transform first get its value updated over the network? AddCallback doesn't seem to work for transforms. I don't see how I can keep the model from rendering if I can't get any notification of when the position has finished syncing.

Thanks!

Comments

  • Untested idea:

    if(state.transform != Vector3.zero)
    state.transform.SetTransforms(transform);
  • the problem is that Vector3.zero is a valid position in my case, it should work though but it would be better if there is a proper way to do this =/
  • There is really no solution for this? I still have no idea how I could prevent things from blinking and teleporting from time to time due to the lack of information of when transforms actually get updated over the network.

    No one else have this problem? How is everyone working around this?

    Using Vector3.zero would be more like a hack and would just "fix" the issue on the moment objects were instantiated in the game, objects being used as a pool, being enabled and disabled as needed would still have this issue since no property is guaranteed to be updated at the same time as any other property so even if something told the object that it is activated in the server the transform could still hold its position from the last time and it would still blink and teleport before getting to its real position.
  • I believe this was fixed on 0.4.3.8
  • I get around it by assigning control once I position the entity.
  • Updated to version 0.4.3.8 and updated all transform code using this.state.SetTransforms instead of the old way to do it, the problem seems to still be here.

    I spawn an item every time a character get killed, sometimes it happens so fast that you don't notice anything wrong but sometimes you can see the item popping up first in the middle of the screen, or even an intermediary position, before it snaps to the right position.

    I can also notice this problem with the player itself since after the first instantiate the player is always in the screen and when it dies, after all the animations and feedback finishes, the visuals are disabled but the gameobject is still in existence so when it respawns you can see it blinking from its last position to its respawn position. This however I think can be fixed just by forcing it to his respawn position as soon as I disable its visuals but the item being instantiated I still don't know how to properly fix it.

    @ddd what do you mean by that? I'm creating the item at the server with BoltNetwork.Instantiate(prefab, position, Quaternion.identity), the server is the one that controls it so I don't do anything else with this object. Do you spawn objects with something other then BoltNetwork.Instantiate?
  • I was talking about assigning control to Player once the server positions it. Thought your client was seeing snapping of the player. So just to clear up your question.

    var yaw = Quantarion.identity
    var pos = new Vector3(50f,0,50f);
    var entity = BoltNetwork.Instantiate(BoltPrefabs.Item, pos, raw);

    Your item will snap from 0,0,0 to 50,0,50 ?
  • yes, that is what is happening, the object is starting with all the visuals turned off and enabling then only at the end of Attached but sometimes you can still see the object blinking in between 0,0,0 and the final position.
  • Same problem here.

    1. Instantiate a boltentity in server at some position with some rotation and without move/rotate.
    2. Starts client and wait boltentity be attached to client, it'll be attached at pos/rot (0,0,0), the Transform state is (0,0,0/0,0,0) and in server, Transform state is correct.

    If I move the entity in server, everything works fine.
    But in new clients the problem persists.

    Unity 5.5.2f1
    Bolt 0.4.4.1 (Debug)
  • Stack
    Stack
    edited May 2019
    Same problem here,

    Bolt v1.2.8, Unity 2019.1.0f2
    Issue still persists in this version, two years later....

    Seeing exact same symptoms as in this thread. when simulating a slow connection interpolation always treats 0,0,0 as the start position, despite the fact the object has been instantiated with a starting position.

    There's also a teleport threshold set, which also appears to have no impact in this scenario...

    Really struggling with how to fix this...
  • Ok, so I came up with an annoying workaround for this which works.
    (Oh, and yes, I know this a thread resurrect, but I came to this thread from google so I hope this helps the next googler)

    So, on the host, I use SetTransforms
    But, on the client, I use AddCallback
    and in the callback function I simply ignore the very first time it gets an update

    like so:
    [code]
    //in Attached()
    if (entity.IsOwner)
    state.SetTransforms (state.Transform, Tandem.transform);
    else
    state.AddCallback ("Transform", OnTransformChanged);

    //callback
    void OnTransformChanged() {
    if(netFrames < 1)
    netFrames++;
    else {
    Tandem.transform.position = state.Transform.Position;
    Tandem.transform.rotation = state.Transform.Rotation;
    }
    }
    [/code]
  • @Stack Could you send a reproduction project so I can take a look?