Runner.Spawn spawn wrong position on a client

Options

When spawning prefab NetworkObject using Runner.Spawn() , host spawn prefab on set position, but on client it is spawned on a default prefab position.

Network object does not have NetworkTransform component.

Am I doing something wrong?

Should I set the position externally?

Please help

Answers

  • WARdd
    WARdd ✭✭
    Options

    I'm guessing if your prefab doesn't have a networktransform or networkrigidbody Fusion assumes the position/rotation doesn't matter. It's a bit silly, since you can still pass null values to position/rotation to make it explicit it doesn't matter, but whatever..

    If you only need to set a single position once you can use

    public override Spawned()

    Which will run on all client simulations. You would have to pass any info you need -say an index pointing to the right spawn point- via OnBeforeSpawned function in Runner.Spawn() and store it in a Networked variable.

    If you need to pass an arbitrary position/rotation or the object can still move over time, you probably just want to give it a NetworkTransform.