Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Can you read and set rope data? for multiplayer purposes.
#1
I am developing a server auth multiplayer game and I need to send rope data to clients to render the rope locally, is this possible?
Reply
#2
(18-11-2022, 03:05 AM)Milionario Wrote: I am developing a server auth multiplayer game and I need to send rope data to clients to render the rope locally, is this possible?

Hi there,

Yes it's possible, you can read and write all per-particle properties at runtime. See the scripting section of the manual:
http://obi.virtualmethodstudio.com/manua...icles.html

Your server should send "snapshots" of the rope as an array of particle positions and velocities. Each time the clients receive the snapshot, write these into their solver data arrays to sync the simulation.

kind regards,
Reply
#3
(18-11-2022, 08:31 AM)josemendez Wrote: Hi there,

Yes it's possible, you can read and write all per-particle properties at runtime. See the scripting section of the manual:
http://obi.virtualmethodstudio.com/manua...icles.html

Your server should send "snapshots" of the rope as an array of particle positions and velocities. Each time the clients receive the snapshot, write these into their solver data arrays to sync the simulation.

kind regards,

Thanks

How many particles are there per meter of rope?
Reply
#4
(18-11-2022, 01:51 PM)Milionario Wrote: Thanks

How many particles are there per meter of rope?

That's completely up to you. It's determined by the blueprint's "resolution" and "thickness" parameters. Thinner, higher resolution particles have more particles per length unit. See:

http://obi.virtualmethodstudio.com/manua...setup.html

kind regards,
Reply
#5
(22-11-2022, 04:12 PM)Milionario Wrote: How do i turn off the simulation on the client? I am setting the positions for the rope but it looks like its trying to simulate at the same time

https://gyazo.com/4749148d2a329fbd49b8507de9d55edc

Hi!

You can disable the solver component.

Note that for networking purposes, you typically wouldn't want to disable simulation, as that will result in choppy behavior when network snapshots do not arrive in a timely manner. You'd want to use dead reckoning, a simple way of doing this is set particle positions and velocities, and allow the client to simulate until a new snapshot arrives.
Reply
#6
(22-11-2022, 04:17 PM)josemendez Wrote: Hi!

You can disable the solver component.

Note that for networking purposes, you typically wouldn't want to disable simulation, as that will result in choppy behavior when network snapshots do not arrive in a timely manner. You'd want to use dead reckoning, a simple way of doing this is set particle positions and velocities, and allow the client to simulate until a new snapshot arrives.
I deleted the post because the problem was that i was setting the positions somewhere else instead of fixed update
Reply
#7
Disabling either the rope or solver makes the rope stop working.

I just want to be able to render the rope on the client side as it was sent from the server, steps to do this?

Currently I am applying the rope data on FixedUpdate

Code:
private void FixedUpdate()
    {
        if (IsServer)
            return;

        for (int i = 0; i < ropeActor.particleCount; i++)
        {
            ropeActor.solver.positions[ropeActor.GetParticleRuntimeIndex(i)] = receivedList[i];
        }
    }


receivedList is a list of rope positions sent by the server, it syncs fine until i deactivate the solver
Reply
#8
(22-11-2022, 07:24 PM)Milionario Wrote: Disabling either the rope or solver makes the rope stop working.

I just want to be able to render the rope on the client side as it was sent from the server, steps to do this?

Currently I am applying the rope data on FixedUpdate

Code:
private void FixedUpdate()
    {
        if (IsServer)
            return;

        for (int i = 0; i < ropeActor.particleCount; i++)
        {
            ropeActor.solver.positions[ropeActor.GetParticleRuntimeIndex(i)] = receivedList[i];
        }
    }


receivedList is a list of rope positions sent by the server, it syncs fine until i deactivate the solver

Oh ok, in that case you can set the particles’ inverse mass to zero, by writing into the solver.invMasses array. This gives them infinite mass and they won’t have any dynamics applied to them.
Reply
#9
(22-11-2022, 07:49 PM)josemendez Wrote: Oh ok, in that case you can set the particles’ inverse mass to zero, by writing into the solver.invMasses array. This gives them infinite mass and they won’t have any dynamics applied to them.

I probably wasn't clear enough, I am saying that if I disable the solver on the client side, the rope doesn't change despite setting its positions like this


Code:
ropeActor.solver.positions[ropeActor.GetParticleRuntimeIndex(i)] = receivedList[i];

I suspect I need to call some solver's update method manually after setting particles positions?
Reply
#10
(23-11-2022, 03:02 AM)Milionario Wrote: I probably wasn't clear enough, I am saying that if I disable the solver on the client side, the rope doesn't change despite setting its positions like this


Code:
ropeActor.solver.positions[ropeActor.GetParticleRuntimeIndex(i)] = receivedList[i];

I suspect I need to call some solver's update method manually after setting particles positions?

My apologies, I was the one not being clear enough.

If you want particles to get updated and rendered, but don't want the simulation to affect them, you must keep the solver enabled, but set particle inverse masses to zero (see "Inverse mass" in the list of exposed particle properties: http://obi.virtualmethodstudio.com/manua...icles.html)

Altenatively, you can extend ObiUpdater to create your own updating component, and skip calling BeginStep/Substep/EndStep in it (search the API docs for "ObiUpdater": http://obi.virtualmethodstudio.com/api.html)

let me know if you need further help with this, and I'll write an example for you.

kind regards,
Reply