Welcome Guest,Register Now
Log In

ANT Forum

Welcome guest, please Login or Register

   

Problem on Unity With ANT+

Rank

Total Posts: 4

Joined 2018-10-13

PM

Hello,

I am a student from Sun-Yat-sen University, China.I am trying to receive speed data from a magnet-less speed sensor in Unity.

Now, I have :
·a ant+ usb stick,
·a speed sensor,
·a x64 win10 PC
·some dll from the sdk

Problem

In the ANT+ SDK 3.5, I modify the c# sub-project "DEMO_NET" which is a c# console app and run , I can receive the speed data from my speed sensor. However, I use the same c# script in Unity, but it doesn't works, saying that


Demo failed with exception:
Could not connect to any device.
Detials:
Arguments cannot be null


I found that the code below doesn't work, in Unity. The device0 here refers to the ANT+ USB STICK in c# sub-project "DEMO_NET", but in Unity, it's null.

device0 = new ANT_Device(); // Create a device instance using the automatic constructor (automatic detection of USB device number and baud rate)



Additonally, the Unity support .Net frame most up to 3.5, so I recompiled the source code in ANT+ SDK. And the needed .dll are placed in the same file, so they should refer each other.
Can somebody help me?

Some Threads in the Forum

the thread 6709 https://www.thisisant.com/forum/viewthread/6709/ says that, there is an unity ant+ asset called ANT+ FOR UNITY, in https://assetstore.unity.com/packages/tools/network/ant-for-unity-57137.But it is unavailable now.

There is also a ant+ library in unity, call "Advanced ANT+", https://assetstore.unity.com/packages/tools/network/advanced-ant-71980 But i.t cost $60, which is too expansive to a student like me.I just develop ant+ with unity for learn instead of commerce.

ATTACHMENT
The attchment is my unity project and the output scene.

ahhhhh, I uploaded the attachments, but can not found them in my post., so I upload they in a cloud-disk, and share.
·the output scene in Unity https://pan.baidu.com/s/1A5eqd-A3CcFqEAgbtVOBDA
·PluginTest.rar: the unity project :https://pan.baidu.com/s/19fdaDXXdKFXid4pgffba9g

if the page is in Chinese, click the button "下载(xxxKB)" for "download(xxxKB)".      
Rank

Total Posts: 2

Joined 2019-03-12

PM

Hi there, wondering if you managed to get this sorted. I'm trying to get data from Ant into Unity as well.      
Rank

Total Posts: 4

Joined 2018-10-13

PM

Hi, dmen.
I did it, howerver, in a ugly way. I start a thread in the C# program to listen a tcp connecttion which respon with the speed once on request. And in the unity, I start a thread to request the speed every 200ms.
It works and it's enough for me to play.If you are developing a stable commercial app, you'd better find a more integrated and more beautiful way.
     
Rank

Total Posts: 2

Joined 2019-03-12

PM

Thanks, I think I will pick up the Advanced ANT asset from the store. Seems like it should work really well.