Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - psavi

Pages: [1]
1
NGUI 3 Support / Touch On Object (TouchJoystick)
« on: April 29, 2015, 11:54:34 AM »
Hello!

I am trying to do a virtual joystick and i was using a script in my camera(it was working well) but now i want to implement the NGUI interface.


This is what i was using :
  1.                
  2.                                 RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.GetTouch(i).position),Vector2.zero);
  3.                        
  4.                                 if(hit.collider != null) {
  5.  
  6.                                 if (hit.collider.name == "Button_Left")
  7.                                 {
  8.  
  9.                                 //the character move to left
  10.                                 }
  11.                                 ..........
  12.        

 I want to know how can i verify if a touch position is colliding a specific object. I have tested in many different ways using the "UIEventListener". The "On Hover Over" option doesn't work well because when i click out of the collider and snap the touch position into the collider it dont trigger. The "On Hover Over" option only trigger when i click first inside the collider area.

I have trying in diferent ways, combining OnPress, OnDrag, Hover.... But dont work as i want. I only want to know the information "if (have a touch position on the button)".

Buttons that use "OnPress" to trigger, like "Jump Event" worked well, but the directional buttons dont...



 If anyone understand what i want to do and make it clear for me, i would be grateful!

Pages: [1]