GearVR Touchpad Swipe Problem
Hi you all,
I have a huge problem with my code to communicate with OVRTouchpad.cs and my Script with player, OVRSwipeJVD.cs.
First when I run the game everything is fine and player interact with OVRTouchpad.cs quite nicely with smooth animation, But after losing or winning a battle the game backs to main menu and from there when I load the same or other levels- My player stops all kind of interaction, in fact I got this msg in console.
I am Using the built in OVRTouchpad.cs nothing changed in these.
Can Anyone help me with it?
Thanks in advance, Take care!
I have a huge problem with my code to communicate with OVRTouchpad.cs and my Script with player, OVRSwipeJVD.cs.
First when I run the game everything is fine and player interact with OVRTouchpad.cs quite nicely with smooth animation, But after losing or winning a battle the game backs to main menu and from there when I load the same or other levels- My player stops all kind of interaction, in fact I got this msg in console.
MissingReferenceException: The object of type 'Animator' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
UnityEngine.Animator.SetBool (System.String name, Boolean value) (at C:/buildslave/unity/build/artifacts/generated/common/modules/Animation/AnimatorBindings.gen.cs:283)
OVRSwipeJVD.HandleTouchHandler (System.Object sender, System.EventArgs e) (at Assets/BOX_scene/OVRSwipeJVD.cs:34)
OVRTouchpad.HandleInputMouse (UnityEngine.Vector3& move) (at Assets/OVR/Moonlight/Scripts/OVRTouchpad.cs:221)
OVRTouchpad.Update () (at Assets/OVR/Moonlight/Scripts/OVRTouchpad.cs:134)
OVRTouchpadHelper.Update () (at Assets/OVR/Moonlight/Scripts/OVRTouchpad.cs:256)
Below I put my OVRSwipeJVD.cs code
// player getting hit
Below I put my OVRSwipeJVD.cs code
using UnityEngine;
using System;
public class OVRSwipeJVD : MonoBehaviour {
public Animator anim;
public Animation animation;
public int restore_timer=0;
void Start () {
OVRTouchpad.Create();
OVRTouchpad.TouchHandler += HandleTouchHandler;
anim = GetComponent<Animator>();
}
void HandleTouchHandler(object sender, System.EventArgs e)
{
restore_timer++;
OVRTouchpad.TouchArgs touchArgs = (OVRTouchpad.TouchArgs)e;
if (touchArgs.TouchType == OVRTouchpad.TouchEvent.SingleTap)
{
//Debug.Log("SINGLE CLICK\n");
}
if (touchArgs.TouchType == OVRTouchpad.TouchEvent.Down)
{
//Debug.Log("DOWN SWIPE\n");
anim.SetBool("Leftblow",true);
restore_timer = 0;
}
if (touchArgs.TouchType == OVRTouchpad.TouchEvent.Up)
{
//Debug.Log("UP SWIPE\n");
anim.SetBool("Rightblow",true);
restore_timer = 0;
}
if (touchArgs.TouchType == OVRTouchpad.TouchEvent.Right)
{
//Debug.Log("RIGHT SWIPE\n");
anim.SetBool("JumpBack",true);
restore_timer = 0;
}
if (touchArgs.TouchType == OVRTouchpad.TouchEvent.Left)
{
anim.SetBool("SwingLeftBlow",true);
restore_timer = 0;
}
if(restore_timer==20)
{
anim.SetBool("BackToMain",true);
anim.SetBool("Rightblow",false);
anim.SetBool("Leftblow",false);
anim.SetBool("SwingLeftBlow",false);
anim.SetBool("MagicThrow",false);
// player getting hit
anim.SetInteger("playerhitmax",0);
anim.SetInteger("playerhit1",0);
anim.SetInteger("playerhit2",0);
anim.SetInteger("playerhit3",0);
anim.SetBool("playerhitmid",false);
restore_timer=0;
}
}
}
I am Using the built in OVRTouchpad.cs nothing changed in these.
Can Anyone help me with it?
Thanks in advance, Take care!
