Runner.Spawn spawn wrong position on a client
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).
Runner.Spawn spawn wrong position on a client
Mikhail123
2023-03-06 14:45:08
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
Comments
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.
Back to top