比较游戏对象增强现实游戏,Unity,Vuforia,C#

比较游戏对象增强现实游戏,Unity,Vuforia,C#,c#,android,unity3d,vuforia,C#,Android,Unity3d,Vuforia,我目前正在制作AR卡游戏,你们需要拿起一对同样的动画,投射在游戏卡上。 共有16种不同的游戏卡,每两种卡上都有使用Vuforia投影的相同动画。 可以同时跟踪2张游戏卡。如果被跟踪的两张卡上的动画相同,我如何比较? 我在编码新手,但需要这样做 public void OnTrackableStateChanged(TrackableBehaviour.Status previousStatus, TrackableBehaviour.Status newStatus) { if

我目前正在制作AR卡游戏,你们需要拿起一对同样的动画,投射在游戏卡上。 共有16种不同的游戏卡,每两种卡上都有使用Vuforia投影的相同动画。 可以同时跟踪2张游戏卡。如果被跟踪的两张卡上的动画相同,我如何比较? 我在编码新手,但需要这样做

    public void OnTrackableStateChanged(TrackableBehaviour.Status previousStatus, TrackableBehaviour.Status newStatus)
{
    if (newStatus == TrackableBehaviour.Status.DETECTED ||
        newStatus == TrackableBehaviour.Status.TRACKED ||
        newStatus == TrackableBehaviour.Status.EXTENDED_TRACKED)

    {
        activeTrackables = sm.GetActiveTrackableBehaviours ();
        MatchCount.cardCount++;
        if (MatchCount.cardCount == 2) { //if there are 2 tracked cards
            //Compare them
            if ( /* first projected animation */ == /* second projected animation */) {
                MatchCount.matches--;

            }



            matchText.text = "number of matches: " + MatchCount.matches;
        }
    }
    else
    {
        MatchCount.cardCount--;
        if (MatchCount.cardCount < 0) {
            MatchCount.cardCount = 0;
        }
        matchText.text = "number of matches: " + MatchCount.matches;
    }
} 
公共无效OnTrackableStateChanged(TrackableBehavior.Status previousStatus,TrackableBehavior.Status newStatus)
{
if(newStatus==trackablebehavior.Status.DETECTED||
newStatus==trackablebehavior.Status.TRACKED||
newStatus==trackablebehavior.Status.EXTENDED\u TRACKED)
{
activeTrackables=sm.getactivetrackablebehaviors();
MatchCount.cardCount++;
如果(MatchCount.cardCount==2){//如果有2张跟踪卡
//比较它们
如果(/*第一个投影动画*/=/*第二个投影动画*/){
MatchCount.matches--;
}
matchText.text=“匹配数:”+MatchCount.matches;
}
}
其他的
{
MatchCount.cardCount--;
如果(MatchCount.cardCount<0){
MatchCount.cardCount=0;
}
matchText.text=“匹配数:”+MatchCount.matches;
}
} 

您可能需要将游戏对象作为游戏对象数组添加到代码中。然后在运行时,尝试在tracker lost and found上使用vuforias将变量设置为“活动”卡/图像目标

一旦您知道哪些已启用,您就可以比较这些卡并找到您想要的匹配项

这里有一个到vuforias板的关于查找活动目标的链接

这是一本指南


首先需要两个对象进行比较。在您的代码示例中,甚至没有一个,除非您正在谈论其中一个的当前
转换
游戏对象