See if player touches a block

Discussion in 'Plugin Development' started by Waterwolf, Mar 17, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    Waterwolf

    Is there another way to check if player touches a block other than comparing distance? Distance comparing works but isn't perfect.
     
  2. Offline

    eltorqiro

    Do you mean if they have waved their hand/tool at it and "hit" it, or if the avatar is touching a particular block?
     
  3. Offline

    Waterwolf

    If the avatar is touching a particular block.
     
  4. Offline

    Edward Hand

    What's wrong with distance measurement?
     
  5. Offline

    Waterwolf

    Im making a portal plugin and yes, distance measuring works but it's still not as accurate as I would like it to be because atm you can pretty much run past portal and it teleports you. I guess I can make it work with distance measurement too though.
     
  6. Offline

    Edward Hand

    Make sure you add 0.5,0.5,0.5 to the x,y,z of the coordinates of the block you're measuring the distance from so that you get the coords of the centre of the block not one corner. It might also be worthwhile measuring the x,y,z distances separately, rather than together, eg:
    Code:
    if(xDist<0.5 && zDist<0.5)
    instead of
    Code:
    if(xDist*xDist + zDist*zDist < 0.5*0.5)
    (since you want to test for position in a box not circle/sphere
     
Thread Status:
Not open for further replies.

Share This Page