Ensure root thing is parented to remote participant
This commit is contained in:
parent
829c4cdd25
commit
dfec91cb62
@ -41,6 +41,7 @@ namespace RoboidControl.Unity {
|
|||||||
GameObject remoteParticipant = new GameObject("RemoteParticipant");
|
GameObject remoteParticipant = new GameObject("RemoteParticipant");
|
||||||
Participant participant = remoteParticipant.AddComponent<Participant>();
|
Participant participant = remoteParticipant.AddComponent<Participant>();
|
||||||
participant.coreParticipant = e.participant;
|
participant.coreParticipant = e.participant;
|
||||||
|
participant.coreParticipant.component = participant;
|
||||||
break;
|
break;
|
||||||
case ThingMsg.id:
|
case ThingMsg.id:
|
||||||
HandleThingEvent(e);
|
HandleThingEvent(e);
|
||||||
|
@ -46,13 +46,18 @@ namespace RoboidControl.Unity {
|
|||||||
protected void Init(RoboidControl.Thing core) {
|
protected void Init(RoboidControl.Thing core) {
|
||||||
this.core = core;
|
this.core = core;
|
||||||
this.core.component = this;
|
this.core.component = this;
|
||||||
this.owner = FindAnyObjectByType<SiteServer>();
|
// This is wrong, it should get the owner, which is not the siteserver
|
||||||
core.owner = this.owner.coreParticipant;
|
// this.owner = FindAnyObjectByType<SiteServer>();
|
||||||
|
// core.owner = this.owner.coreParticipant;
|
||||||
|
this.owner = core.owner.component;
|
||||||
|
|
||||||
if (core.parent != null && core.parent.component != null) {
|
if (core.parent != null && core.parent.component != null) {
|
||||||
this.transform.SetParent(core.parent.component.transform, false);
|
this.transform.SetParent(core.parent.component.transform, false);
|
||||||
this.transform.localPosition = Vector3.zero;
|
this.transform.localPosition = Vector3.zero;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
this.transform.SetParent(core.owner.component.transform, false);
|
||||||
|
}
|
||||||
|
|
||||||
if (core.position != null)
|
if (core.position != null)
|
||||||
this.transform.localPosition = core.position.ToVector3();
|
this.transform.localPosition = core.position.ToVector3();
|
||||||
@ -108,7 +113,7 @@ namespace RoboidControl.Unity {
|
|||||||
case ThingMsg.id:
|
case ThingMsg.id:
|
||||||
Debug.Log($"{this.core.id} Handle Thing");
|
Debug.Log($"{this.core.id} Handle Thing");
|
||||||
if (core.parent == null)
|
if (core.parent == null)
|
||||||
this.transform.SetParent(null, true);
|
this.transform.SetParent(core.owner.component.transform, true);
|
||||||
else if (core.parent.component != null)
|
else if (core.parent.component != null)
|
||||||
this.transform.SetParent(core.parent.component.transform, true);
|
this.transform.SetParent(core.parent.component.transform, true);
|
||||||
break;
|
break;
|
||||||
|
@ -52,6 +52,14 @@ namespace RoboidControl {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public int port = 0;
|
public int port = 0;
|
||||||
|
|
||||||
|
#if UNITY_5_3_OR_NEWER
|
||||||
|
/// <summary>
|
||||||
|
/// A reference to the representation of the thing in Unity
|
||||||
|
/// </summary>
|
||||||
|
[NonSerialized]
|
||||||
|
public Unity.Participant component = null;
|
||||||
|
#endif
|
||||||
|
|
||||||
public UdpClient udpClient = null;
|
public UdpClient udpClient = null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user