Playmaker Forum

Playmaker Help & Tips => VR Help => Topic started by: detomato on August 23, 2016, 02:03:46 PM

Title: Gaze Timer
Post by: detomato on August 23, 2016, 02:03:46 PM
Hi, is there any gaze timer action available? Already searched the forum, but nothing with the said function. And theres a tut from Youtube which doesnt work as expected.

Basically need an action when an object is gazed for certain amount of time.

Thanks.
Title: Re: Gaze Timer
Post by: topscore1632 on September 05, 2016, 06:08:34 AM
I did this by basically having a long thin box as a child of the camera. So effectively the same as attaching a pole to your head. Then you put triggers around the objects you're trying to interact with and just look for collisions between the pointer object and the triggers.
Title: Re: Gaze Timer
Post by: jeanfabre on September 05, 2016, 11:22:38 PM
Hi,

 It's a good approach indeed. but would require some fiddling around if you wanted to control UI elements too.

 For UI gaze controls, I created a sample on the Ecosystem.

(http://i.imgur.com/1gSFvxM.png)

Bye,

 Jean
Title: Re: Gaze Timer
Post by: DinaHaines on January 25, 2017, 02:13:29 AM
In summary, create a script to time the gaze, by cumulatively adding Time.deltaTime on each frame when the object is gazed at. When gaze time hits a pre-specified duration, trigger the button's OnClick event.

On the object, activate the script's gaze timing functions using event triggers Pointer Enter and Pointer Exit.
Title: Re: Gaze Timer
Post by: PET on March 15, 2017, 03:54:11 AM
Hello guys!

What is the best way for this?

Basically I want to have 2 buttons... and I want a button to only trigger when you look at it for like 3 seconds or something. Eventually it would be nice to have an indication... like the button filling up or something.

Thank You!

EDIT:
@Jean - I found your Gaze thingie on the EcoSystem, however it generates an error:

(http://i.imgur.com/lg5QkWF.png)
Title: Re: Gaze Timer
Post by: jeanfabre on March 15, 2017, 05:32:24 AM
Hi,

 yes, good catch, I have fixed the packaging, please get it again from the ecosystem.

 Bye,

 Jean
Title: Re: Gaze Timer
Post by: PET on March 15, 2017, 05:38:30 AM
No error right now. I will test this some more after lunch.

Is there a way to have some kind of bar "filling" to indicate that you have to look at the buttons?

THanks
Title: Re: Gaze Timer
Post by: PET on March 15, 2017, 07:40:10 AM
Ok. I'm doing a test. I have an Oculus installed & I'm testing the demo scene, the one with the 2 buttons.

Nothing happens if I look at the buttons. I see a red dot in the center of the screen in the EDITOR, but no red tot on Oculus.

But again, nothing happens when I look at the buttons in the demo scene.

EDIT:
(http://i.imgur.com/gPwAPYL.png)

It seems that this is not triggering.
Title: Re: Gaze Timer
Post by: jeanfabre on March 15, 2017, 10:42:55 PM
Hi,

 This demo works by moving the mouse around to move the scene, it's likely that with the oculus, you have a different mechanism and the raycasting may simply shoot in a different direction.

is the red dot above the buttons?

 Bye,

 Jean
Title: Re: Gaze Timer
Post by: PET on March 16, 2017, 01:25:30 AM
I can't really move the mouse around the scene because my Oculus is connected and it's overwriting the movement. I'm moving around the scene with Oculus itself... and like that it's not working.

In the past I used to do some VR interactions with MOuse Look At (or something similar) ... because the mouse cursor was hidden but always present in the middle. This didn't worked on VR because there the rotation is somehow overwriten so I had to change the interaction.

It's a bit weird that I can't really test the buttons when I actually have an Oculus which is what... it being targeted for.
Title: Re: Gaze Timer
Post by: jeanfabre on March 16, 2017, 05:19:45 AM
Hi,

 this sample is a sample showing how to implement a generic gaze button, it doesn't assume the oculus will be used nor any other device, the example works only by moving the mouse around to move the view around. It should work however if you switch the camera movement to be matching the VR headset, and I am not sure what's happening here.

-  do you see the red dot and is it over the button when you move your head a
round? and when the red dot is over, nothing happens?

- are you playing this scene as is or did you modified it? maybe something is in the way and covers the button hence the button doesn't receive it?

Bye,

 Jean
Title: Re: Gaze Timer
Post by: PET on March 16, 2017, 06:47:07 AM
All I did was to open the scene. No modifications.

I can't move the camera with the mouse, because the Oculus is overwiting any movement. Even if I don't touch the oculus (I left it on the table), the transform values are constantly moving:
https://streamable.com/qpj67

if I manualy turn the oculus to look at a button, nothing happens.

I don't see a red dot on oculus, only in the editor.

I'm 100% sure that I'm looking at the buttons. I even tried to look for 10 seconds at the buttons... nothing happens.

(http://i.imgur.com/UcWd2H8.png)

The Screen Point is always at 671.0, 184.0, 0.0. Never moving.
Title: Re: Gaze Timer
Post by: jeanfabre on March 16, 2017, 07:32:07 AM
Hi,

 First, there must be a gaze point, else something it wrong:

 please check this screenshot, the gaze point is a regular image in a canvas, if you don't have this, then we must understand first why you don't.

 (http://i.imgur.com/GVuXbUy.png)

 then, I guess either you are missing the ugui proxy ( also feature in this screenshot inspector browser
).

Bye

 Jean
Title: Re: Gaze Timer
Post by: PET on March 16, 2017, 07:34:24 AM
I'm using the exact scene that comes with the project from the EcoSystem.

(http://i.imgur.com/7xk0PIJ.png)


What other files did you changed in yesterday's bug report? Only that "RectTransformWorldToScreenPoint.cs"? Because I only re-downloaded that file.
Title: Re: Gaze Timer
Post by: jeanfabre on March 16, 2017, 10:59:08 PM
Hi,

 can you show your game view, if the image is there in the hierarchy, it's should be visible in the game view.

I am not sure waht you mean with the last sentence:
"What other files did you changed in yesterday's bug report? Only that "RectTransformWorldToScreenPoint.cs"? Because I only re-downloaded that file."

what bug report are you refering to? you should update the gaze sample, not just that file.

 Do you still have errors in the console?

Bye,

 Jean
Title: Re: Gaze Timer
Post by: PET on March 17, 2017, 02:03:30 AM
(http://i.imgur.com/XyoKtj8.png)

This is a screenshot with the game view. The red dot is vissible, I look at the button, but nothing happens.

I don't get any more errors. I updated the Gaze thingie, but it only downloads the files I am missing, so I deleted the RectTransformWorldToScreenPoint.cs which had the error 2 days ago... I updated... so this new .cs file got downloaded. No more errors.

But I'm thinking that maybe 2 days ago you modified other files that havnt' been updated on my PC.

(http://i.imgur.com/h8kvaon.png)

Is there any way to fast delete those files so I can re-download the package? This is one of the things I hate in Unity. You can't Uninstall Assets fast :)

Anyway, I deleted the majority of Gaze files. Did a reimport ... same thing.

Here, I even made a video:
https://streamable.com/zy2gd
Title: Re: Gaze Timer
Post by: jeanfabre on March 20, 2017, 02:09:58 AM
Hi,

apart from this missing file, all seems ok. Something is very wrong here.

which version of the Oculus do you have?

 Bye,

 Jean

 
Title: Re: Gaze Timer
Post by: PET on March 20, 2017, 02:19:56 AM
I have the consumer version of Oculus.
Title: Re: Gaze Timer
Post by: PET on March 20, 2017, 02:14:26 PM
Hello Jean,

I just tested this at home. Same project... but no occulus. It works fine!!!

Is there a way to debug the raycast? I'm curious to see how it's being drawn.
Title: Re: Gaze Timer
Post by: jeanfabre on March 20, 2017, 11:16:40 PM
Hi,

 yeah, odd. So it's either the Canvas and graphic raycaster that is not setup properly to work with the oculus, or the wway the oculus control the camera makes raycasting faulty somewhere along the line, at least with the technic used.

and indeed, doing some researched leads me to this:

https://forum.unity3d.com/threads/unity-5-2-vr-raycast-solved.361211/

 Where it seems we can't use any default camera orientation for some reason.

 I also found this: https://forums.oculus.com/developer/discussion/16710/new-unity-ui-ovr-look-based-input-howto

can you try this component and follow the instructions? it that works, then great.

Let me know how it goes.

 Bye,

 Jean

Title: Re: Gaze Timer
Post by: PET on March 21, 2017, 04:29:24 AM
That's a pretty old post from the Oculus forums. 2014.

Btw. I had a project last year where I used OnMouseOver action. SOmething like that. The cursor was always in the middle hidden, so it made sense to use it. No Raycast used.

However in VR this didn't worked because the Oculus Camera overwites the movement. Meaning... even that I move left/right/up/down with my head, the cursor still remained in the "center of a screen".

Makes sense?
Title: Re: Gaze Timer
Post by: jeanfabre on March 21, 2017, 10:43:37 PM
Hi,

 I would nonetheless give it a go. I haven't found anything better on paper when googling for this.

 Bye,

 Jean
Title: Re: Gaze Timer
Post by: PET on March 22, 2017, 02:16:38 AM
I will look into that project... but from what I see... it's for Unity 4.
I see that there are some pages there. Some guy says this:

(http://i.imgur.com/86BqIY0.png)

Btw. As a test, I decided to place a Raycast on the camera. It looks like this:
(http://i.imgur.com/lQg42Jd.png)

So the raycast can be casted correctly. Can't we just use a normal raycast and check when we hit the UI buttons? The UI buttons are in world space anyway and they can have a colider.
Title: Re: Gaze Timer
Post by: PET on March 22, 2017, 03:37:43 AM
Hey Jean. Have a look at this:

https://streamable.com/jgokx


:))

The whole thing is not 100% precise... like I have to look a little bit down in order to trigger the button.

https://streamable.com/hwoga
Title: Re: Gaze Timer
Post by: jeanfabre on March 22, 2017, 07:05:34 AM
Hi,

 Yes, and actually, if you updated uGui from the proxy, you have a new component that matches colliders to the Ui element, so it will be a lot more convenient now. More infos below:

https://twitter.com/JeanAtPlayMaker/status/842327318441910273

 I think it's a hack, and I would recommand searching for the real source of the problem, but of course if raycasting works ( though it's odd it's offseted...)

 I would ask the community on how they do it, because I am using straight Unity api within the actions and they should work, if it's not working here, I think everyone is facing this...

you could try this too as well: https://github.com/polats/gvr-unity-sdk/blob/master/Samples/CastleDefense/Assets/OVRInspector/Scripts/OVRRaycaster.cs


 Bye,

 Jean
Title: Re: Gaze Timer
Post by: PET on March 22, 2017, 07:11:54 AM
Well I don't have to use a Raycast. The problem was the Mouse Look from the Camera orbit FSM.

(http://i.imgur.com/tVfXwpe.png)

If I disable this, I can Gaze the UI buttons using Oculus! Ofc, as you said, it's a bit offset, but I will use your new small script.
Title: Re: Gaze Timer
Post by: PET on March 23, 2017, 08:19:03 AM
(http://i.imgur.com/0Enazl1.png)

Am I not adding the Box Collider 2d Match Rect Transform correctly?
I have added it to the Button A & B which contains the Image (Script).

It does add that collier ... however the colider is not rotated corectly ... the camera raycast is still a little bit offset.

Not a huge deal... I can still use this... I'm just curious on how to do this correctly.

Thanks
Title: Re: Gaze Timer
Post by: jeanfabre on March 23, 2017, 11:20:33 PM
Hi,

 ah crap yes, it only works on overlay settings...

I'll do a 3d physics version of this component, that should fix it. Please ping me early next week if I haven't done it yet.


 Bye,

 Jean
Title: Re: Gaze Timer
Post by: PET on March 27, 2017, 07:12:12 AM
did a small test with that scene on GearVR. button work but the problem is that small dot. in editor the red dot works but in gearvr it doesn't show up. it was the same in my oculus PC build test.

--------

The only way to see the Red dot is to set up the Canvas to "Screen Space - Camera". But of course, that is not going to trigger the buttons anymore :(
Title: Re: Gaze Timer
Post by: PET on March 28, 2017, 10:51:33 PM
Ok. I fixed the RED DOT problem... by making another Canvas that was set up to Screen Space - Camera!

The game window looks like this:
(http://i.imgur.com/PZtO0Pd.png)

So... turns out ... that the default gaze was not in the center of the screen... which is why it was the whole button was offsetting. LOL

So, with that new Gaze... I can see a red dot on the Oculus... and the triggering works fine :))


I still find this whole process a bit MEH.

I feel that we require way to many things. Playmaker UGui, then you need those 2 scripts:
(http://i.imgur.com/qTQ4UuJ.png)

Then you need the buttons logic, then the gaze logic, etc.

Well I understand part of the logic... I just don't understand why we also need to have the above 2 scripts.

Look ... a video:
https://streamable.com/o80mp
Title: Re: Gaze Timer
Post by: jeanfabre on March 29, 2017, 01:53:54 AM
Hi,

 very good, I am glad you got to the bottom of this.

 PlayMaker uGui is the proxy between Unity UI and PlayMaker, without it, you'll have to do write scripts to let PlayMaker know about anything UI, so it's mandatory if you don't know how to code, and actually, even if you know, I would still recommand to use it as it's a lot of work to provide such proxy, so you should capitalize on this and avoid waisting time and reinventing the wheel, IF this proxy is suitable for you of course :) If not, you are perfectly welcome to write your own.

check the Fsm involved in this demo to understand why it's needed. In your game of course the buttons will do different thing and hopefully more than just switching the background color :)

 Bye,

 Jean
 Bye,

 Jean
Title: Re: Gaze Timer
Post by: PET on March 29, 2017, 01:56:33 AM
Check this out:
https://streamable.com/0sxx2

:D
Title: Re: Gaze Timer
Post by: jeanfabre on March 29, 2017, 01:59:55 AM
Cool :)
Title: Re: Gaze Timer
Post by: PET on March 29, 2017, 02:02:25 AM
Basically I am able to check if a file exists, if not I can download it from my server using Easy Save (they have nice playmaker integration).

then I can play the file... the file is an actual 360 video that get's downloaded & stored into the device.

(http://i.imgur.com/3bDcUFg.png)

All Playmaker. This is only the Loading scene.
Title: Re: Gaze Timer
Post by: PET on May 09, 2017, 02:25:39 AM
Damn. After the latest upgrade to 5.6 the whole Gaze thing is not working anymore. Now I have to debug this again :D

Yea. Did an update from EcoSystem... demo scene doesn't work. And I made sure to disable the mouse look (since I'm moving the camera with oculus)

EDIT: But it works if I unplug the Oculus. WTF MAN
Title: Re: Gaze Timer
Post by: jeanfabre on May 11, 2017, 06:30:52 AM
Hi,

 crap... Let me know how it goes. I think we should then gather your findings into a dedicated scene we tag as oculus compatible, I am sure a lot of devs will appreciate this.

Let us know how it goes :)


 Bye,

 Jean
Title: Re: Gaze Timer
Post by: PET on May 15, 2017, 10:17:04 PM
I have no idea what's the problem yet... but until then I have another question.

I'm trying to make my system less hardcoded. I have a system now that is Using Array Maker List, etc etc. Basically I'm able to check and activate the appropriate buttons for PLAY or DOWNLOAD.

So if I look at a button that says Play, it will send an event for Play. My problem is that I need to know what Button send the Play event, as I will have multiple buttons that can have the Play state.

(http://i.imgur.com/c5zw5N6.png)

As you can see here. Both buttons are in the "Play" mode, so both of them can send the Play Event.

-----------------------------------------

I did this by using Get Event Info. I'm getting the Game Object, and then I'm checking the Tag of the Game Object which is already set up by me. SO I'm good :)
Title: Re: Gaze Timer
Post by: jeanfabre on May 17, 2017, 01:09:47 AM
Hi,

 excellent,

Bye,

 Jean