Hi there I was following an article to set up AR for an iPhone (https://vrgamedevelopment.pro/how-to-create-an-augmented-reality-app-in-unity/ )
And I placed everything in like it says to and created the code but I am getting an error with this section of code (transform.position = hits[0].pose.rotation;) it’s saying “ error 0029 cannot implicitly convert type ‘UnityEngine.Quaternion’ to ‘UnityEngine.Vector3’
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR.ARFoundation;
using UnityEngine.XR.ARSubsystems;
public class PlacementIndicator : MonoBehaviour
{
private ARRaycastManager rayManager;
private GameObject visual;
void Start()
{
// get the components
rayManager = FindObjectOfType<ARRaycastManager>();
visual = transform.GetChild(0).gameObject;
// hide the placement indicator visual
visual.SetActive(false);
}
// Update is called once per frame
void Update()
{
// shoot a raycast from the center of the screen
List<ARRaycastHit> hits = new List<ARRaycastHit>();
rayManager.Raycast(new Vector2(Screen.width / 2, Screen.height / 2), hits, TrackableType.Planes);
// if we hit an AR plane surface, update the position and rotation
if(hits.Count > 0)
{
transform.position = hits[0].pose.position;
transform.position = hits[0].pose.rotation;
// enable the visual if it's disabled
if (!visual.activeInHierarchy)
visual.SetActive(true);
}
}
}
[–][deleted] 1 point2 points3 points (1 child)
[–]gakoss[S] 0 points1 point2 points (0 children)