Hallo there. I tried to start animation play when raycast hited my 3D model after touch screen. Vuforia track my 3D object by picture.
My script on 3Dmodel in imageTarget but when i try to test project on android device it raycast and play animation just once... can you help me
to understand what i did wrong? p.s REALY BIG THX TO ANYONE!
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI;
public class InputGameController : MonoBehaviour {
Animator anim;
bool fire
string result;
int choice = 0;
void Start() { anim = GetComponent<Animator>(); fire = false; }
void Update() { Raycastresult(); }
void Raycastresult() {
if (Input.touchCount > 0 && Input.touches[0].phase == TouchPhase.Began) { Ray ray = Camera.main.ScreenPointToRay(Input.GetTouch(0).position); RaycastHit Hit; if (Physics.Raycast(ray, out Hit)) { result = Hit.transform.name; Debug.Log("Raycast Hit!"); playerChoiceAtack(result); Debug.Log("GoTo Switch cases"); } }
return; }
void playerChoiceAtack(string playerTag) { Debug.Log("Start Switch"); switch (playerTag) { case "bear": Debug.Log("Start Bear Animation"); fire = true;
if(fire==true) anim.SetBool("AtackBear", true);
fire = false;
break;
case "arhar": Debug.Log("Start arhar Animation");
fire = true;
if(fire==true) anim.SetBool("AtackArhar", true);
fire = false;
//if (fire == false) // anim.SetBool("AtackArhar", false);
break;
}
}