I was watching a 3-year-old tutorial for Vuforia and it's freezing the content and modifying it instead of the possibility of an uncomfortable position. the code looked fine and very well explained although I'm using TrackableBehaviour and it keeps showing me an error that it doesn't exist, at first thought I might didn't download Vuforia correctly, but I don't think this is the case anymore. if someone knows what is the problem or an alternative solution please tell me.
c#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Vuforia;
public class TIH : MonoBehaviour
{
public GameObject picture; // Reference to the augmentable picture GameObject
private TrackableBehaviour trackableBehaviour; // Reference to the TrackableBehaviour component
private float touchTime; // Stores the time when the touch begins
private bool isPictureFrozen = false; // Flag to check if the picture is frozen
void Start()
{
// Get the TrackableBehaviour component of the augmentable picture
trackableBehaviour = picture.GetComponentInParent<TrackableBehaviour>();
}
void Update()
{
if (Input.touchCount == 1) // Single touch
{
Touch touch = Input.GetTouch(0); // Get the touch
if (touch.phase == TouchPhase.Began) // Touch started
{
touchTime = Time.time; // Store the time when the touch began
}
else if (touch.phase == TouchPhase.Ended && (Time.time - touchTime) >= 1.0f && !isPictureFrozen) // Touch ended, duration >= 1 second, and picture not frozen
{
FreezePicture(); // Freeze the picture
}
}
else if (Input.touchCount == 2) // Two-finger touch
{
Touch touch1 = Input.GetTouch(0); // Get the first touch
Touch touch2 = Input.GetTouch(1); // Get the second touch
if (touch1.phase == TouchPhase.Moved || touch2.phase == TouchPhase.Moved) // One or both touches moved
{
float pinchDistance = Vector2.Distance(touch1.position, touch2.position); // Calculate the distance between the two touches
float pinchDelta = (touch1.deltaPosition - touch2.deltaPosition).magnitude; // Calculate the change in distance between the two touches
// Scale the picture based on the pinch gesture
picture.transform.localScale *= 1 + pinchDelta * Time.deltaTime;
}
}
}
private void FreezePicture()
{
isPictureFrozen = true; // Set the flag to indicate the picture is frozen
trackableBehaviour.enabled = false; // Disable the TrackableBehaviour component to stop tracking the augmentable image
}
}
tried to redownload the vuforia package, download another version of unity that might be supported, nothing worked.