(27-09-2023, 08:59 PM)fevzi Wrote: moved all to the EndStep function but tension still not syncing Code
There's lots of issues with your code:
- I don't know which networking system are you using, but this code:
Code:
public void OnEnable()
{
if (IsClient)
{
GetComponent<ObiActor>().OnEndStep += EndStep;
}
}
Looks as if only the client subscribes to OnEndStep. In OnEndStep you're checking whether the subscriber "IsServer" before sending data, but since only clients subscribe, no data will ever be sent. Might be the case that the server is also a client, but you should definitely look into this just in case.
- You're synchronizing invRotationalMasses: which is only used by oriented particles in rods. It is unused by ropes.
- You're synchronizing invMasses, these values don't change at runtime (unless you explicitly change them) so no need to synchronize them.
- You're synchronizing externalForces and externalTorques, which as the name implies they're used to inject external forces/torques into the simulation and will be zero unless you explicitly set their values. No need to synchronize.
- You're not synchronizing startPositions and prevPositions, which are used to interpolate physics state, so state interpolation will break.
- You're not synchronizing velocities (may or may not be needed for your specific use case).
- You're using rope.GetParticleRuntimeIndex(i), which returns the index of the particle either in the actor or the solver. This is intended to be used when writing editor tools only, at runtime you should use rope.solverIndices instead.
I'd suggest taking a look at the scripting section of the manual for details.