playMaker

Author Topic: Mouse Click Ray Distance Problem  (Read 3720 times)

fromfame

  • Junior Playmaker
  • **
  • Posts: 78
  • Sloppy PM Veteran
Mouse Click Ray Distance Problem
« on: April 16, 2013, 08:30:13 AM »
Hey, so i've got an item set up (a book) and whenever i hover over it, it glows blue and shows me its name in GUI as "Book".

that's awesome, only problem is that the Book GUI shows at a distance of 5 although the glow is accessible from an infinite distance, how can i fix this?

fromfame

  • Junior Playmaker
  • **
  • Posts: 78
  • Sloppy PM Veteran
Re: Mouse Click Ray Distance Problem
« Reply #1 on: April 16, 2013, 08:41:03 AM »
Sorry i forgot to mention that i understand the picture below is what leads to it being infinite, although how can i control this? i've pasted the "Mouse Click" action with its specified functions all around the book's FSM although i can't fix this.


Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Mouse Click Ray Distance Problem
« Reply #2 on: April 16, 2013, 08:51:20 AM »
What are you doing for the glow? Anything that operates outside the Over state? You may need to add something that disables the glow in the idle state.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

fromfame

  • Junior Playmaker
  • **
  • Posts: 78
  • Sloppy PM Veteran
Re: Mouse Click Ray Distance Problem
« Reply #3 on: April 16, 2013, 09:04:06 AM »
Its alright that isn't the problem, i've told told the glow to reset on exit, on the 3rd frame from the first post im actually pointing my mouse on it from a big distance when it told it just "5"

the problem is that the GUI gets that "ok, the ray's above 5 so i'll disappear" but the glow doesn't because of the second post i put up.

i just want to know how to have the glow which is on "over" and "down" actions to respect the ray distance which is 5, and the second post i have is obviously not the solution lol

fromfame

  • Junior Playmaker
  • **
  • Posts: 78
  • Sloppy PM Veteran
Re: Mouse Click Ray Distance Problem
« Reply #4 on: April 16, 2013, 09:07:22 AM »
Here's the main thing operating all this

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Mouse Click Ray Distance Problem
« Reply #5 on: April 16, 2013, 09:14:05 AM »
I would recommend doing it the other way around, otherwise objects like the book will all constantly be testing the distance to see if they should be glowing.

On the raycasting state use a float compare to see if your distance variable is less than 5 between the corresponding object and then use a send event. Maybe after it sends the event the object can "activate" and start checking the distance to the player, then disable itself if the player is more than 5 away. That would be more efficient.

Something similar to that, its just off the top of my head. You do need a float test either way on the distance but I would recommend doing as much as possible in your raycasting state to avoid making every interactive object constantly running an fsm and distance check actions unnecessarily.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

fromfame

  • Junior Playmaker
  • **
  • Posts: 78
  • Sloppy PM Veteran
Re: Mouse Click Ray Distance Problem
« Reply #6 on: April 16, 2013, 09:35:51 AM »
God,
i wish i could come up with things like that on the fly, sadly i still consider myself more of a designer and barely a coder haha

im currently trying out what your saying and it makes complete sense, tho something hit me, doesn't "Mouse Pick Event" solve this easier?

its got all the mouse over, off, up, down actions built in and a ray cast that i can set along with an option to use a game object with a collider.

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Mouse Click Ray Distance Problem
« Reply #7 on: April 16, 2013, 09:52:53 AM »
Yeah that would probably work even better. Use it every frame, store the picked object and I would also make an "Interactive" Tag/layer for any interactive objects and use that as a mask for the pick so it isn't constantly sending events to props and other junk that your mouse is constantly moving over.

You may want to have an idle state on your FSM that is doing the mouse pick event so that you can exit that state and idle and waiting for a return event from the object to "release" it, letting you do other things with the interactive object without having to worry about exiting the mouse over state and sending an exit event annoyingly while you're messing with the object and also to make sure the mouse pick event doesn't keep sending the mouse over event in a loop. Just some ideas.

Always look for other actions to use (like you just have), there are many ways to do what you want :)
« Last Edit: April 16, 2013, 09:54:29 AM by Lane »
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D