RoboidControl-csharp/Sensors/DistanceSensor.cs
2025-02-19 13:08:32 +01:00

27 lines
786 B
C#

using System;
namespace Passer.RoboidControl.Core {
public class DistanceSensor : Thing {
public float distance = 0;
public DistanceSensor(RemoteParticipant participant) : base(participant, true) { }
public DistanceSensor(RemoteParticipant participant, byte networkId, byte thingId) : base(participant, networkId, thingId, (byte)Type.TemperatureSensor) {
}
#if UNITY_5_3_OR_NEWER
public override void CreateComponent() {
this.component = Unity.DistanceSensor.Create(this.parent);
this.component.core = this;
}
#endif
public override void ProcessBinary(byte[] bytes) {
byte ix = 0;
this.distance = LowLevelMessages.ReceiveFloat16(bytes, ref ix);
}
}
}