vuforia 飛行機の実装

1,飛行機を設置し、プロペラ部分にRotate.csをつける。Rotate.csは下記。
![C404C8A0-9E64-4B5F-B03F-A880AEE972FC.jpeg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/940521/2b3e59cf-66a7-abae-c022-16769ccebf52.jpeg)

```C#: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を作成し、飛行機にアタッチする。下記コードを記述。

```C#: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](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/940521/c49516bf-c269-40f5-debb-f2e624cbaefd.jpeg)

2, チェックをつける
![B784C11B-9F84-4F88-92E9-C680C7CD0C07_4_5005_c.jpeg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/940521/c0f2a50a-e426-23a5-44f1-a95ef51ff6f5.jpeg)

3, 雲用も設定する
![073AD829-F11D-43C1-B768-EDBDB666BB77_4_5005_c.jpeg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/940521/58957842-2008-e127-177f-ab5b8f3b15e9.jpeg)

4, 同様にTargetLostも設定する（チェックは外す）
![94A231EB-687B-49D7-A66F-76CD5ACFD5BB_4_5005_c.jpeg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/940521/ee0990d2-f8ae-dcb6-0320-6f63e8f67fc9.jpeg)

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

1, Cubeを作成し、リセット位置に置く
![2603DAEA-4ED8-41DF-A820-01EFF758062E_4_5005_c.jpeg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/940521/bd539047-7d37-5a93-2712-65cde1666cf5.jpeg)

2, BoxColliderをつけ、チェックをつける
![876B96EB-6F70-4272-A987-F3C27886C292.jpeg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/940521/fe4ae2c5-da0b-15a6-a5ab-3e3af74e70ec.jpeg)

3, 飛行機にBoxColliderとRigidBodyをつけ、チェックと各調整をする
![8515F85B-56E6-46A7-B1B9-353F0E028994.jpeg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/940521/5daabfab-a156-aedb-870d-f2a8e9f14cc6.jpeg)

4, CubeにAEROPLANEWALLのTagを作成し、つける
![91673A7D-F551-443E-9C59-83246DD05673_4_5005_c.jpeg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/940521/9b7c0862-3880-ce3d-b808-11851f8fd624.jpeg)
![43862754-7FA1-4635-AE21-FC7C2737DD1F_4_5005_c.jpeg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/940521/cc95ea13-92f4-c74e-7183-d78ed7eac798.jpeg)

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

```C#: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](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/940521/2fa8eeb5-6744-c2bc-2875-c4ff7c70fca1.jpeg)

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

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

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

    }
```