- Home /
Animate gameobject when collided with another gameobject using VRTK
Hi, i want to animate door. in my case when i grab the key and collide it with door lock, doorsopen animation should play. am doing with htc vive and vrtk.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using VRTK;
public class collisionCheck : MonoBehaviour {
public GameObject animObject;
Animator animObjectAnimator;
bool grab;
void Start () {
animObjectAnimator = animObject.GetComponent<Animator> ();
animObjectAnimator.enabled = false;
}
void OnTriggerEnter(Collider other)
{
print ("My name: "+other.gameObject.name);
if (other.gameObject.name == "doors") {
grab = false;
grab = GetComponent<VRTK.VRTK_InteractableObject> ().IsGrabbed ();
animObjectAnimator.enabled = true;
animObjectAnimator.SetInteger ("AnimValue", 1);
}
}
the same i have tried in pc mode using input.getkey its working fine. but when used htc vice it is detecting collisions on controller, other gameobject collisions are not detecting properly. some times they are detecting but animation is not working.
Comment