- Home /
Using Collision to trigger animation in AR environment using Vuforia
Hi, I'm new to unity and c#. I'm currently trying to develop an AR app using Vuforia, and I have the problem to set the collision as the trigger for the animation attached with the object. The two objects are activated by the same marker. Is there a way to drag object A to B and cause a collision between the two, which can then trigger the animation?
(I've tried Lean touch for dragging, but the function seems to be disabled when I add the animation to the animator controller and it won't allow me to drag the object.)
Any help or recommending tutorials can literally save my life!!! Thanks! ##
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CollideWithSlide : MonoBehaviour
{
private Animator anim;
private bool collision = false;
void Start()
{
anim = GetComponent<Animator>();
Debug.Log("anim activated");
}
void OnTriggerEnter(Collider other){
Debug.Log("hit detected*********");
collision = true;
}
void OnTriggerExit(Collider other){
Debug.Log("exit!!!!!!!!!!!!!!");
}
void Update()
{
if(collision == true){
anim.Play("DonutAnim", -1, 0f);
}
}
}
Comment