x


Joystick Raycast Problem?

Hi to all)) I use if(Physics.Raycast(ray, out hit, 4.0f)){ for placing or delete block on screen position touch. But even if i touch my Joystick or another button, raycast delete block when i touch my Joystick. I allready try to use LayerMask but with no succes How can i ignore my Joystick from RayCasting? Can any one help me with this? Here the part of my code:

if (Input.GetMouseButtonDown(0)){ 
if(buttonTimer == 0){
if(hand.gameObject.active == true){ 
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if(Physics.Raycast(ray, out hit, 4.0f)){    
Vector3 hitPoint = hit.point + (ray.direction.normalized * 0.01f);
IntVect blockHitPoint = new IntVect((int)hitPoint.x, (int)hitPoint.z,    (int)hitPoint.y);
m_World.Dig(blockHitPoint, hitPoint);
}
buttonTimer = buttonCoolDown;
}
}

Please some one help me figure it out. I search this forum, and find some answer, but it didnt help me(

I update code to use Touch Input, but problem is still.

  if (Input.touchCount == 1 ) {
    Touch touch = Input.touches[0];
    if(hand.gameObject.active == true){ 
    if(touch.phase == TouchPhase.Began){
    if(buttonTimer == 0){
    Ray ray = Camera.main.ScreenPointToRay(touch.position);
    RaycastHit hit;
    if(Physics.Raycast(ray, out hit, 4.0f)){    
    Vector3 hitPoint = hit.point + (ray.direction.normalized * 0.01f);
    IntVect blockHitPoint = new IntVect((int)hitPoint.x, (int)hitPoint.z, (int)hitPoint.y);
    m_World.Dig(blockHitPoint, hitPoint);
    }   
    buttonTimer = buttonCoolDown;
    }
    }
    }
    }
more ▼

asked Jan 11 '12 at 10:27 PM

Head@Hunter gravatar image

Head@Hunter
1 1 2

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

I made it by miself) Here Solution:

if (leftJoy.HitTest( Input.mousePosition )) {

              return;

          }
more ▼

answered Jan 12 '12 at 02:21 AM

Head@Hunter gravatar image

Head@Hunter
1 1 2

(comments are locked)
10|3000 characters needed characters left

I made it by miself)) Here solution: if (leftJoy.HitTest( Input.mousePosition )) {

              return;

          }
more ▼

answered Jan 12 '12 at 02:21 AM

Head@Hunter gravatar image

Head@Hunter
1 1 2

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1999
x1946
x1528
x578
x7

asked: Jan 11 '12 at 10:27 PM

Seen: 430 times

Last Updated: Jan 12 '12 at 02:21 AM