0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

vuforia 飛行機の実装

Last updated at Posted at 2021-07-26

1,飛行機を設置し、プロペラ部分にRotate.csをつける。Rotate.csは下記。
C404C8A0-9E64-4B5F-B03F-A880AEE972FC.jpeg

Rotate
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Rotate : MonoBehaviour
{
    public Vector3 vect;

    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        transform.Rotate(vect * Time.deltaTime);
    }
}

2, Transrate.csを作成し、飛行機にアタッチする。下記コードを記述。

Transrate
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Transrate : MonoBehaviour
{
    public Vector3 moveObject;
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        transform.Translate(moveObject * Time.deltaTime);
    }
}

ImageDefaultの設定

1, imageTargetのDefaultTrackableを設定する
523272BA-A1AF-4C75-B51B-8D9C978E6DDA.jpeg

2, チェックをつける
B784C11B-9F84-4F88-92E9-C680C7CD0C07_4_5005_c.jpeg

3, 雲用も設定する
073AD829-F11D-43C1-B768-EDBDB666BB77_4_5005_c.jpeg

4, 同様にTargetLostも設定する(チェックは外す)
94A231EB-687B-49D7-A66F-76CD5ACFD5BB_4_5005_c.jpeg

飛行機の位置をリセットするCubeの作成

1, Cubeを作成し、リセット位置に置く
2603DAEA-4ED8-41DF-A820-01EFF758062E_4_5005_c.jpeg

2, BoxColliderをつけ、チェックをつける
876B96EB-6F70-4272-A987-F3C27886C292.jpeg

3, 飛行機にBoxColliderとRigidBodyをつけ、チェックと各調整をする
8515F85B-56E6-46A7-B1B9-353F0E028994.jpeg

4, CubeにAEROPLANEWALLのTagを作成し、つける
91673A7D-F551-443E-9C59-83246DD05673_4_5005_c.jpeg
43862754-7FA1-4635-AE21-FC7C2737DD1F_4_5005_c.jpeg

5, ResetPosition.csを作成し、飛行機にアタッチする

Reset
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ResetPosition : MonoBehaviour
{
    Vector3 originalPos;
    // Start is called before the first frame update
    void Start()
    {
        originalPos = transform.localPosition;
    }

    // Update is called once per frame
    void Update()
    {
        
    }

    private void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.CompareTag("AEROPLANEWALL"))
        {
            transform.localPosition = originalPos;
        }
    }
}

6, Materialを作成し、Fadeで色を透明にしてCubeにアタッチする
3A663CDA-C512-44AE-8790-0B87FCFDC4B4.jpeg

7,雲用のCubeも同様に作成し、下記スクリプトを追加する

ResetPosition
private void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.CompareTag("AEROPLANEWALL"))
        {
            transform.localPosition = originalPos;
        }

        else if (other.gameObject.CompareTag("CLOUDWALL"))
        {
            transform.localPosition = originalPos;
        }

    }
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?