playMaker

Author Topic: Question regarding length of Mouse Over  (Read 423 times)

FunD

  • Playmaker Newbie
  • *
  • Posts: 29
    • View Profile
Question regarding length of Mouse Over
« on: March 25, 2019, 04:55:58 PM »
Hi,

I'm using 'Mouse Over' States quite a lot in my Adventure Game. To start dialogues with NPC's after hovering the mouse over them, picking up objects, displaying UI Texts.. etc. (see screenshot below)

It's all working fine. Except one problem, that I can't figure out. Basically, the length of the mouse over..
So if I point at an object all the way across the room, although I'm super far, it executes the 'Mouse Over' actions.

Do you know how to change that? That would be really helpful, I'm pretty stuck on this one.

Thanks
Screenshot:
https://ibb.co/5ktmQgd

Athin

  • Full Member
  • ***
  • Posts: 118
    • View Profile
Re: Question regarding length of Mouse Over
« Reply #1 on: March 25, 2019, 05:17:49 PM »
Hey there

So what exactly are you trying to do with your project?  I'm assuming you only want to pick up objects that are close to the character/camera? 

What you need to do if thats the case is just do a simple distance check to whatever you're using.  When an object gets mouse over event, have it do a quick compare using the distance from the object itself to the object you are limiting. 

Let me know if that helps otherwise let me know a bit more about the project itself so I can help better.

Thanks

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4541
    • View Profile
    • jinxtergames
Re: Question regarding length of Mouse Over
« Reply #2 on: March 26, 2019, 12:33:05 AM »
Hi.
You might want to use, 'Mouse Pick' and/or 'Mouse Pick Event' instead.
With these actions you can set the ray distance.

FunD

  • Playmaker Newbie
  • *
  • Posts: 29
    • View Profile
Re: Question regarding length of Mouse Over
« Reply #3 on: March 26, 2019, 05:30:34 AM »
Hey there

So what exactly are you trying to do with your project?  I'm assuming you only want to pick up objects that are close to the character/camera? 

What you need to do if thats the case is just do a simple distance check to whatever you're using.  When an object gets mouse over event, have it do a quick compare using the distance from the object itself to the object you are limiting. 

Let me know if that helps otherwise let me know a bit more about the project itself so I can help better.

Thanks


Hello,
I am attaching Screenshots to this message of what I have now. Basically, when the player hovers over a certain object with the mouse, a UI Text appears (Text: 'Press E to get more info'), and then on key down (E), a new UI Text appears on the Screen. And when the player points the mouse cursor away from the object, the UI Text disappears again. I have the same mechanics for picking up objects and starting dialogues etc.

But the problem is that the player can be standing really far away from the object and still the UI Text 'Press E to get more info' appears when placing the cursor on the object.

How do I apply a distance check on what I currently have? I tried 'Get Distance' and 'Raycast' but have not been able to make it work yet.

Screenshots:
https://ibb.co/JmMtbDk
https://ibb.co/xgCrH0x
https://ibb.co/pWN06vh
« Last Edit: March 26, 2019, 05:37:21 AM by FunD »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4541
    • View Profile
    • jinxtergames
Re: Question regarding length of Mouse Over
« Reply #4 on: March 26, 2019, 09:31:08 AM »
Hi.
'Mouse Pick Event' Should work.

but if you have many objects i would use a different approach.
Many listeners (mouse over/ mouse pick events) would not be so good for performance.

a better way would be :

a fsm doing mouse pick every frame and store game object.

Then another fsm and use 'Fsm Game Object Changed' (Ecosystem)

When changed, check gameobject in an array and get the index.

Then have a 2nd array with the "Press 'E' to get more info" objects.
And with the index you got from the 1st array you can now get the object that you should activate.

Another way, IF the "Press 'E' to get more info", is the same on each object, you could also get the game object position.
and move the "Press 'E' to get more info" to the game object.
Then you can also check if no gameobject by using "Game Object Is Null" and if null disable the "Press 'E' to get more info"

To get the 'Educational Text' you could also use the index and have an array with them.
Have another fsm with a state with get key down and have a global transition to it (enabled)
also have a another state state and have nothing in it, also add a global transition (disabled)

on state after get key down use get fsm int, to get the index....


Scratch the above, just get the attachment below, you can find a sample scene in it and some custom actions from the ecosystem that where needed for the sample.

its easier to understand if you see.

if you have difficulties to understand, let me know and i will make a video on it :)

FunD

  • Playmaker Newbie
  • *
  • Posts: 29
    • View Profile
Re: Question regarding length of Mouse Over
« Reply #5 on: March 26, 2019, 01:28:53 PM »
Hi.
'Mouse Pick Event' Should work.

but if you have many objects i would use a different approach.
Many listeners (mouse over/ mouse pick events) would not be so good for performance.

a better way would be :

a fsm doing mouse pick every frame and store game object.

Then another fsm and use 'Fsm Game Object Changed' (Ecosystem)

When changed, check gameobject in an array and get the index.

Then have a 2nd array with the "Press 'E' to get more info" objects.
And with the index you got from the 1st array you can now get the object that you should activate.

Another way, IF the "Press 'E' to get more info", is the same on each object, you could also get the game object position.
and move the "Press 'E' to get more info" to the game object.
Then you can also check if no gameobject by using "Game Object Is Null" and if null disable the "Press 'E' to get more info"

To get the 'Educational Text' you could also use the index and have an array with them.
Have another fsm with a state with get key down and have a global transition to it (enabled)
also have a another state state and have nothing in it, also add a global transition (disabled)

on state after get key down use get fsm int, to get the index....


Scratch the above, just get the attachment below, you can find a sample scene in it and some custom actions from the ecosystem that where needed for the sample.

its easier to understand if you see.

if you have difficulties to understand, let me know and i will make a video on it :)


Hi,

Thank you very much for the help.
I am also sending you a sample scene :) Maybe it makes things easier

..So I imported your Scene with the 'Mouse Pick Handler'. I have a 'Mouse Pick Handler' object now in my Scene.

What I'm confused about, is how does the 'Mouse Pick Handler' link to specific objects in the scene that are supposed to release the 'Press E to get more information' and display of Educational Text.
I tried to figure it out in your sample scene. How is it linked to the 3 cubes exactly?

When I originally did it with 'Mouse Over', (it's in my attached sample scene as well) the FSM was on a collider, so I could place that collider wherever in the scene, where it's supposed to release an educational text when standing close to it.

With the 'Mouse Pick Handler' I have in my scene now, it just detects all objects that have a collider in the scene I think. So not specific spots.
It also does not display the UI Educational Text for some reason.

I need basically three different mouse over actions:
- One that releases Educational Texts
- One for picking up objects
- One for starting a dialogue system with NPC's.

I created three different UI Text objects for that. It's in my sample scene.

I also left the 'Picking up Object on Mouseover and clicking 'E' object, and the 'Object releasing Educational Text on Mouse over' object. Those work, they just have that distance issue I mentioned earlier.
The new Mouse Pick Handler is also in there.

Would I need three different Mouse Pick Handlers in my scene? One for dialogues, one for picking up objects and one for educational texts?

A video would definitely help a lot, or explaining why this scene I am sending you doesn't work. Thank you so much for your time and thanks for your patience on my newbie questions

Sample Scene, download-link:
https://we.tl/t-rR31Rnr4Kd

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14500
  • Official Playmaker Support
    • View Profile
Re: Question regarding length of Mouse Over
« Reply #6 on: March 28, 2019, 02:37:08 AM »
Hi,

 mouse detection is based on collider, simply remove the colliders of object you don't want to interact with the mouse, if that's possible that would be the best option.

 you can setup a LOD component, that the far version just doesn't have a collider and that's it.

 Bye,

 Jean

FunD

  • Playmaker Newbie
  • *
  • Posts: 29
    • View Profile
Re: Question regarding length of Mouse Over
« Reply #7 on: March 28, 2019, 08:08:27 PM »
Hi,

Thanks for your answer.

Mouse detection might not make much sense for me then, because most objects in my game have colliders..

I never heard of LOD until you mentioned it, so I read some Unity documentation about it today and see how to use that

Hi,

 mouse detection is based on collider, simply remove the colliders of object you don't want to interact with the mouse, if that's possible that would be the best option.

 you can setup a LOD component, that the far version just doesn't have a collider and that's it.

 Bye,

 Jean

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4541
    • View Profile
    • jinxtergames
Re: Question regarding length of Mouse Over
« Reply #8 on: March 29, 2019, 12:05:21 AM »
Hi.
Sorry for the late reply.

the mouse pick has a layer mask.
With this you select only the layers that you want to detect, or you can invert and detect every thing except the selected ones.

to know which object when pressed E, i store the picked object and also have all the objects in an array.
Then i check if the array (world object) contains the selected object
if it has, then i store the index nr and use that to get the correct text.