Я использую LeanTouch + для перевода объекта, но он может перемещаться только по Y на основе экрана Android, поэтому на камере объект можно перемещать только вверх и вниз.То, чего я пытаюсь достичь, - это возможность перемещать объект дальше или ближе к виду с камеры.В ARCore вы сначала обнаруживаете окружение, а затем оно генерируется как Plane, и это плоскость, в которой мне нужен объект для перемещения.
Также, если возможно, я хочу использовать Зажим на «обнаруженной плоскости», чтобы ограничить движение дальше, чем обнаруженная плоскость
вот мой код для создания объекта с использованием LeanFingerTap
public void Spawn(LeanFinger finger)
{
if (AndyPlanePrefab != null && finger != null)
{
// Raycast against the location the player touched to search for planes.
TrackableHit hit;
TrackableHitFlags raycastFilter = TrackableHitFlags.PlaneWithinPolygon |
TrackableHitFlags.FeaturePointWithSurfaceNormal;
if (Frame.Raycast(finger.ScreenPosition.x, finger.ScreenPosition.y, raycastFilter, out hit))
{
if(currentNumberofPrefab<numberOfPrefabsAllowed)
{
currentNumberofPrefab = currentNumberofPrefab + 1;
// Use hit pose and camera pose to check if hittest is from the
// back of the plane, if it is, no need to create the anchor.
if ((hit.Trackable is DetectedPlane) &&
Vector3.Dot(FirstPersonCamera.transform.position - hit.Pose.position,
hit.Pose.rotation * Vector3.up) < 0)
{
Debug.Log("Hit at back of the current DetectedPlane");
}
else
{
// Choose the Andy model for the Trackable that got hit.
if (hit.Trackable is FeaturePoint)
{
AndyPrefab = AndyPointPrefab;
}
else
{
getValue = ItemScrollList.valuePrefab;
if (getValue == 1)
{
AndyPrefab = AndyPlanePrefab[0];
Debug.Log("value 1");
}
else if (getValue == 2)
{
AndyPrefab = AndyPlanePrefab[1];
Debug.Log("value 2");
}
else if (getValue == 3)
{
AndyPrefab = AndyPlanePrefab[2];
Debug.Log("value 3");
}
else if (getValue == 4)
{
AndyPrefab = AndyPlanePrefab[3];
Debug.Log("value 4");
}
else if (getValue == 5)
{
AndyPrefab = AndyPlanePrefab[4];
Debug.Log("value 5");
}
}
// Instantiate Andy model at the hit pose.
var andyObject = Instantiate(AndyPrefab, hit.Pose.position, hit.Pose.rotation);
//adding tag to andyObject for destroying spawn purposes
andyObject.tag = "HomePrefab";
// Compensate for the hitPose rotation facing away from the raycast (i.e. camera).
andyObject.transform.Rotate(0, k_ModelRotation, 0, Space.Self);
// Create an anchor to allow ARCore to track the hitpoint as understanding of the physical
// world evolves.
var anchor = hit.Trackable.CreateAnchor(hit.Pose);
// Make Andy model a child of the anchor.
andyObject.transform.parent = anchor.transform;
}
}
}
}
}