1,飛行機を設置し、プロペラ部分にRotate.csをつける。Rotate.csは下記。
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を設定する
4, 同様にTargetLostも設定する(チェックは外す)
飛行機の位置をリセットするCubeの作成
3, 飛行機にBoxColliderとRigidBodyをつけ、チェックと各調整をする
4, CubeにAEROPLANEWALLのTagを作成し、つける
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にアタッチする
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;
}
}