Added wal texutre & minor improvements

This commit is contained in:
Pascal Serrarens 2025-04-24 12:59:05 +02:00
parent a6d6ec1948
commit 3d2374436c
2 changed files with 15 additions and 2 deletions

View File

@ -16,6 +16,8 @@ namespace RoboidControl.Unity {
get => (RoboidControl.TouchSensor)base.core; get => (RoboidControl.TouchSensor)base.core;
} }
SphereCollider collider = null;
/// <summary> /// <summary>
/// Start the Unity represention /// Start the Unity represention
/// </summary> /// </summary>
@ -24,6 +26,7 @@ namespace RoboidControl.Unity {
participant = FindAnyObjectByType<SiteServer>(); participant = FindAnyObjectByType<SiteServer>();
SetCoreThing(new RoboidControl.TouchSensor(participant.site)); SetCoreThing(new RoboidControl.TouchSensor(participant.site));
} }
collider = GetComponent<SphereCollider>();
} }
/// <summary> /// <summary>
@ -42,7 +45,7 @@ namespace RoboidControl.Unity {
rb.isKinematic = true; rb.isKinematic = true;
SphereCollider collider = gameObj.AddComponent<SphereCollider>(); SphereCollider collider = gameObj.AddComponent<SphereCollider>();
collider.radius = 0.02f; collider.radius = 0.01f;
collider.isTrigger = true; collider.isTrigger = true;
if (gameObj.transform.parent != null && gameObj.transform.localPosition.magnitude > 0) { if (gameObj.transform.parent != null && gameObj.transform.localPosition.magnitude > 0) {
@ -53,6 +56,16 @@ namespace RoboidControl.Unity {
return component; return component;
} }
protected override void Update() {
base.Update();
if (collider.radius == 0.01f &&
this.transform.parent != null && this.transform.localPosition.magnitude > 0
) {
collider.radius = Vector3.Distance(this.transform.position, this.transform.parent.position) / 2;
this.transform.position = (this.transform.position + this.transform.parent.position) / 2;
}
}
private void OnTriggerEnter(Collider other) { private void OnTriggerEnter(Collider other) {
Debug.Log("Touch?"); Debug.Log("Touch?");
if (other.isTrigger) { if (other.isTrigger) {

View File

@ -37,9 +37,9 @@ namespace RoboidControl {
get { return _touchedSomething; } get { return _touchedSomething; }
set { set {
if (_touchedSomething != value) { if (_touchedSomething != value) {
touchUpdated = true;
_touchedSomething = value; _touchedSomething = value;
} }
touchUpdated = true;
} }
} }
private bool touchUpdated = false; private bool touchUpdated = false;