【问题标题】:Comparing game objects Augmented reality game, Unity, Vuforia, C#比较游戏对象 增强现实游戏、Unity、Vuforia、C#
【发布时间】:2017-05-02 21:50:33
【问题描述】:

我目前正在制作 AR 纸牌游戏,您需要在游戏卡上选择一对相同的动画。 有 16 种不同的游戏卡,每张 2 都使用 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;
    }
} 

【问题讨论】:

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

标签: c# android unity3d vuforia


【解决方案1】:

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

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

这里是 vuforias 板的链接,用于查找活动目标。

https://developer.vuforia.com/forum/unity-extension-technical-discussion/active-script-when-image-target-detected

这里有一个指南

https://developer.vuforia.com/forum/faq/unity-how-do-i-get-list-active-trackables

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-25
    相关资源
    最近更新 更多