- Home /
How to make particle system enabled by looking at something in Google Cardboard VR
Hi all!
Long time no see in this place of www space ;) For couple of days I'm struggling with new modifications for Google Cardboard (which made almost every tutorial not helpful at all since)
My problem is: Working on Unity 5.4.3f1 Personal I want to make certain effects (Particle System) available after looking on something. One effect I need right in the moment when player look at something (telling him or her: "hey! You can interact with me!" Second is when he or she concentrate his gaze enough to unlock certain action. I have no problem with the second kind, but first one is giving me hard time.
What I did: I have modified GvrReticle script put as a child on my Player I added public GameObject AuraMenu (that's my particle system), and I set this to false at Start(). It's working. I can make it to being showed as the long after 3 seconds effect as the effect of GazedAt. But I want it to be started right away if my player is looking on it. And Right now is being showed at the start of the scene which makes it just pure stupid solution.
public void OnGazeStay(Camera camera, GameObject targetObject, Vector3 intersectionPosition,
bool isInteractive)
{
SetGazeTarget(intersectionPosition, isInteractive);
if (gazedAt != null && gazeStartTime > 0f)
{
AuraMenu.SetActive(true); //here is where I need it to work
if (Time.time - gazeStartTime > 3.0f && ExecuteEvents.CanHandleEvent<TimedInputHandler>(gazedAt))
{
//here I can make this work but it's too late for me
gazeStartTime = -1f;
ExecuteEvents.Execute(gazedAt, null, (TimedInputHandler handler, BaseEventData data) => handler.HandleTimedInput());
}
}
}
Thank you in advance for any given help and I hope that the solution will be helpful to other devs as well :)