Fix many RemoteParticipants in Unity

This commit is contained in:
Pascal Serrarens 2025-06-06 17:54:16 +02:00
parent 7f063e0434
commit ad8e587f65
3 changed files with 16 additions and 9 deletions

View File

@ -49,14 +49,13 @@ namespace RoboidControl.Unity {
Participant participant = remoteParticipant.AddComponent<Participant>();
participant.coreParticipant = e.participant;
participant.coreParticipant.component = participant;
ParticipantUDP participantUDP = participant.coreParticipant as ParticipantUDP;
if (participantUDP != null) {
if (participant.coreParticipant is ParticipantUDP participantUDP) {
participant.ipAddress = participantUDP.ipAddress;
participant.port = participantUDP.port;
}
foreach (RoboidControl.Thing thing in this.site.things)
participant.coreParticipant.SendThingInfo(thing);
participant.coreParticipant.SendThingInfo(thing);
break;
case ThingMsg.id:

View File

@ -120,7 +120,7 @@ namespace RoboidControl {
public override byte Serialize(ref byte[] buffer) {
if (poseType == 0)
return 0;
#if DEBUG
#if DEBUG2
System.Console.WriteLine($"Send PoseMsg [{this.networkId}/{this.thingId}] {this.poseType}");
#endif

View File

@ -325,12 +325,13 @@ namespace RoboidControl {
if (sender == null) {
sender = AddParticipant(ipAddress, endPoint.Port, this);
sender.isRemote = true;
}
UpdateEvent e = new() {
messageId = NetworkIdMsg.Id,
participant = sender
};
UpdateEvent e = new() {
messageId = NetworkIdMsg.Id,
participant = sender
};
}
this.updateQueue.Enqueue(e);
ReceiveData(data, sender);
@ -457,6 +458,7 @@ namespace RoboidControl {
// Console.Write($"Dropped {thing.id}");
thing.parent = null;
}
ForwardMessage(sender, msg);
}
@ -479,6 +481,8 @@ namespace RoboidControl {
Thing thing = sender.Get(msg.thingId);
if (thing != null)
thing.name = msg.name;
ForwardMessage(sender, msg);
}
protected virtual void Process(Participant sender, ModelUrlMsg msg) {
@ -489,6 +493,8 @@ namespace RoboidControl {
Thing thing = sender.Get(msg.thingId);
if (thing != null)
thing.modelUrl = msg.url;
ForwardMessage(sender, msg);
}
protected virtual void Process(Participant sender, PoseMsg msg) {
@ -511,6 +517,8 @@ namespace RoboidControl {
thing.linearVelocity = msg.linearVelocity;
if ((msg.poseType & PoseMsg.Pose_AngularVelocity) != 0)
thing.angularVelocity = msg.angularVelocity;
ForwardMessage(sender, msg);
}
protected virtual void Process(Participant sender, BinaryMsg msg) {