playMaker

Author Topic: Mouse pick and NGUI problem  (Read 6947 times)

Sebuturn

  • Playmaker Newbie
  • *
  • Posts: 5
Mouse pick and NGUI problem
« on: January 13, 2014, 07:43:30 AM »
Hi,

I have a problem using playmaker and NGUI. I'm creating a top down mouse driven game. And my mousepick go through my NGUI buttons. It's probably something really easy to do, but I can't figure it out.

What I'm trying to do is that my character move when I click on the ground. This work great with the other 3D objects of the scene (doing a Tag compare) but with the NGUI it seems to simply go through (it doesn't detect the object).

mikejkelley

  • Full Member
  • ***
  • Posts: 136
Re: Mouse pick and NGUI problem
« Reply #1 on: January 14, 2014, 03:33:43 PM »
In the UISprite (Script) panel in the widget box there's a check box for Box Collider. Make sure that's checked.

Use the UIEvents To Playmaker FSM (Script) to best integrate w/ Playmaker.

Sebuturn

  • Playmaker Newbie
  • *
  • Posts: 5
Re: Mouse pick and NGUI problem
« Reply #2 on: January 15, 2014, 05:03:28 AM »
Thanks for the answer :) I've done that.

From what I gathered during my investigation (but I'm not sure) The problem should be that the mousepick raycast is sent from the main camera? And thus is doesn't go through the sprite on the NGUI camera?

The workaround I found is to put a child object to the main camera that is visually at the same position than the button.

It's not clean at all, but it works for the moment :)

mikejkelley

  • Full Member
  • ***
  • Posts: 136
Re: Mouse pick and NGUI problem
« Reply #3 on: January 15, 2014, 06:35:29 PM »
You shouldn't be using raycast, it's better to use "on click event" from the inspector of the UIEvents To Playmaker FSM (Script). I think the script might only be available through fog buzz which is an unfortunately under-reported highly awesome resource!

https://hutonggames.fogbugz.com/default.asp?W714
« Last Edit: January 16, 2014, 02:07:30 AM by mikejkelley »

Sebuturn

  • Playmaker Newbie
  • *
  • Posts: 5
Re: Mouse pick and NGUI problem
« Reply #4 on: January 16, 2014, 05:41:20 AM »
I'm not using raycast for the GUI but just for the mousepick action on my character controller. And that's the raycast that's causing the issue. Basically, when I click on my button, it does the action perfectly, but the mouse pick still fires and my character moves to the mousepicked location.

I'm using the UIEvents to Playmaker on the GUI (and it is indeed an awesome resource :) )

mikejkelley

  • Full Member
  • ***
  • Posts: 136
Re: Mouse pick and NGUI problem
« Reply #5 on: January 16, 2014, 02:44:01 PM »
oh i c, then try using on click event to send an additional global event to your char that dead-ends.

SeanP

  • Playmaker Newbie
  • *
  • Posts: 3
Re: Mouse pick and NGUI problem
« Reply #6 on: March 07, 2014, 02:46:38 PM »
I too am having a similar issue, I have gameObjects I want to click on, that all works, I can tell what I am clicking on and store the objects, however if I click on an NGUI element, it behaves as though I am clicking on another object from the main camera. I realize why this is (mousepick is sending a raycast from main cam, not the UI cam.) But how can I get around this? Making the UI camera follow the main cam would work technically, but its sloppy and wont help with UI scaling.

Any help would be great.

blackant

  • Hero Member
  • *****
  • Posts: 521
  • http://blackantmaster.com
    • blackantmaster.com
Re: Mouse pick and NGUI problem
« Reply #7 on: March 08, 2014, 02:59:29 AM »
yes your main camera is used for raycasting, check that the both camera are using same size and that the distance with NGUI is good especially if the main camera is as perspective mode, it can have some position difference with the 2Dcamera UI as it is as orthographic view
« Last Edit: March 08, 2014, 03:01:04 AM by blackant »

mikejkelley

  • Full Member
  • ***
  • Posts: 136
Re: Mouse pick and NGUI problem
« Reply #8 on: March 24, 2014, 03:12:02 AM »
My suggestion to Sebuturn was that the NGUI button, when clicked, send a global transition event that basically shorted (turned off) raycast/mouspick.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Mouse pick and NGUI problem
« Reply #9 on: April 08, 2014, 08:06:41 AM »
Hi,

 use Ngui pick system only when working with Ngui, else you will have nightmares...

 What's not working with the event bridge component?

Bye,

 Jean