配置好环境之后,将一个cube放在imagetarget上面。并且设置一个plane,属性为shadows only
再ARCamera的子物体Camera上挂上脚本goThere.cs(注意一定要挂在Camera上,挂在ARcamera上就无法运行)
然后点击运行,在点击的时候这个物体就能移动到点击的位置了。
using UnityEngine;
using System.Collections;
public class goThere : MonoBehaviour
{
public Camera cam;
private Vector3 hitPoint;
public GameObject meinv;
public float speed = 30;
// Use this for initialization
void Start()
{
cam = this.GetComponent<Camera>();
}
// Update is called once per frame
void Update()
{
if (Input.GetMouseButtonDown(0))
{
Ray ray = cam.ScreenPointT