#Struggling with simple netcode for entities w/physics setup

1 messages · Page 1 of 1 (latest)

silent fox
#

here is my setup
https://github.com/Chambrse/netcodephysics

the docs say:
https://docs.unity3d.com/Packages/com.unity.netcode@1.2/manual/physics.html

"This works without any configuration but will assume all dynamic physics objects are ghosts, so either fully simulated by the server (interpolated ghosts), or by both with the client also simulating forward (at predicted/server tick) and server correcting prediction errors (predicted ghosts), the two types can be mixed together. To run the physics simulation only locally for certain objects some setup is required."

https://docs.unity3d.com/Packages/com.unity.netcode@1.2/manual/networked-cube.html

I just have a single subscene with the plane and sphere. the sphere is positioned above the plane. the sphere has components as in the screenshot. Then I use the basic game.cs and goingame.cs setup as described in the networked cube example linked above. It does not include the cube-player specific stuff because for now I don't care about ghosts with owners or input, I just want some physics objects to simulate on the server and update on the client. the connection piece seems to work just fine, but the sphere just hovers there mocking me. In the scene view, the sphere falls according to physics. That's all the converted subscene stuff though I'm pretty sure and does not indicate that successful snapshots are being sent.

Thank you for any advice!

GitHub

hello world unity ECS + netcode for entities + physics - Chambrse/netcodephysics

silent fox
#

I'd be happy to talk with anyone who has any practice with net code for entities even previous versions if you can't answer my question.

fallow herald
#

i haven't used netcode in a while but if i recall there used to be a bug where the client physics won't tick unless at least 1 ghost exists

silent fox
#

I think I saw that thread, but this is my entity hierarchy. ghosts are there in both server and client worlds. Thank you for your input! any other ideas?

fallow herald
#

wait is your cube not a ghost?

silent fox
#

I don't have a cube. the networked cube example doesn't include physics so I figured it'd be easier to just simulate some non-owned ghosts from a static camera with no "player" to start.

#

there are some examples but I don't think there are any with physics for netcode 1.2

fallow herald
#

things that aren't a ghost won't simulate

#

non-ghosts need to simulate in a second separate physics world you need to setup

#

and then copy them into the simulated physics world

silent fox
#

well my sphere is a ghost. it just doesn't have an owner. My goal for an entity like this is that it would be consistent between clients and therefore must be a ghost. So I've added a ghost authoring component to the game object in the subscene along with the sphere authoring script as shown in my initial screenshots. might I be missing something setting up an entity as a ghost?

fallow herald
#

ok that makes more sense

#

sorry i missinterpreted your first message

#

you need to check your server world to see if it's actually ticking to start with

#

and what components are on your cube?

silent fox
#

There isn't a cube yet. just the sphere. I'll be happy to add a player but I don't think it's required to just watch the sphere bounce from the client

fallow herald
#

either look at a profiler

#

or the system window

silent fox
#

looks kosher to me, what do you think?

fallow herald
#

not seeing hte fixed update / physics run here

silent fox
#

ServerFixedUpdate is there, and within it, there are multiple different simulationsystemgroups. ghostsimulationsystemgroup, fixedstepsimulationgroup, predictedsimulationsystemgroup, more.

fallow herald
#

yeah they'll be there but is it updating

silent fox
#

Thanks again for your input so far but I'll have to revisit this tomorrow

fallow herald
#

Tbh I'd just get the default setup first then add your own stuff(physics)

#

But just to confirm you did make your physics object dynamic right

#

So it does fall

spice socket
#

a good test is put a ground plane in the subscene, and then spawn your sphere up in the air, if it falls and lands on the ground plane, physics is working.

silent fox
# fallow herald Tbh I'd just get the default setup first then add your own stuff(physics)

That's what I tried first. I started with networked cube and tried to add some non owned ghost spheres with a spawner, so very much following the paradigms in the networked cube example. I managed to get a spherespawnersystem working on the server and from the client the spheres would spawn, but again they would just float there. So that's why I simplified it down to just having a sphere prefab in the subscene to see if that would work and then I could build up.

silent fox
silent fox
silent fox
# fallow herald yeah they'll be there but is it updating

This is my first time opening the systems window. to me it seems like these are all running. is there something more specific I can look for? my thoughts being that my sphere might not be included in the correct systems that handle physics by default?

spice socket
#

not sure if it's relevant here, but "running" doesn't mean "updating" or "has entities that match the queries", if you look in the Entity Count column not all of them have entities that match the queries. They might also have a RequireForUpdate<> set, and I believe they would still show up in this window but not call Update.

so make sure you're double checking that when using this window.

silent fox
#

There are only three user-defined cs scripts in this setup. so I haven't actually defined any systems other than the most basic goingame systems that the networked cube example provides. based on my original quote from the docs:

https://docs.unity3d.com/Packages/com.unity.netcode@1.2/manual/physics.html

"This works without any configuration but will assume all dynamic physics objects are ghosts, so either fully simulated by the server (interpolated ghosts), or by both with the client also simulating forward (at predicted/server tick) and server correcting prediction errors (predicted ghosts), the two types can be mixed together. To run the physics simulation only locally for certain objects some setup is required."

#

so I do think I'm missing something, but I don't know what. that quote suggests that converted rigid bodies are handled by physics simulation by default. I also wonder about by sphere baker. it's very basic.

silent fox
#

bump 🙂

wide yoke
wide yoke
silent fox