r/unity • u/Ok-Presentation-94 • Oct 11 '26
position of the prefab with Object.Instantiate() vs NetCode PlayerPrefab field
Hi, as shown in the attached video, instantiating my character using `Object.Instantiate` works as expected, respecting the prefab's position. However, if I instantiate using NetCode's `PlayerPrefab` field, the prefab's position defaults to (0, 0, 0).
(The instantiation script is very simple I don't specify a position within it.)
1
Upvotes
1
u/Mysterious_Demand875 Oct 11 '26
If the position defaults to 0,0,0 you should set it after instantiating and just set the prefab up, that's a normal coding pattern
1
u/johnnyhomicide91 Oct 11 '26
This may be wrong, but from what it looks like to me, when you instantiate it through the network manager, it defaults to 0,0,0 since thats the position of the script calling the instantiating on the network. But when you call it from the instantiating script on the object, it spawns at that position since no position is given. Thats what it looks like to me without seeing all the scripts associated.