0
\$\begingroup\$

I have a question regarding the exact method for getting the game object that I'm touching. I thought it would be getting the name of the PressGesture once the touch starts...but it returns me a Swipe Controller object name, so that is not the correct. I have read, though not extensively, the TouchScript documentation, but I haven't found a method that gets information from the point you are touching/clicking

This is the code that tries to solve that issue (of course, the wrong way):

private void pressedHandler(object sender, EventArgs e)
{
    PressGesture gesture = sender as PressGesture;
    TouchHit hit;
    gesture.GetTargetHitResult (out hit);
    startPos = hit.Point;

    if(gesture.gameObject == this.swipePositions[0])
    {
        Debug.Log ("Pressed on: " + gesture.gameObject.name + " at: " + startPos);
    }
    else
    {
        Debug.Log("Not even from the start...");
        Debug.Log("This name is: " +gesture.gameObject.name);
        Debug.Log("The name should be: " +this.swipePositions[0].name);
    }
}
\$\endgroup\$

1 Answer 1

0
\$\begingroup\$

Solved. It works similar to the Raycasting without the TouchScript Asset....there is an GameObject called TouchHit, and it has both RaycastHit and RaycastHit2D properties, I just needed to cast a ray where the hit was touch, and get its transform.gameObject, and that's pretty much it I guess.

Thanks.

\$\endgroup\$
1
  • \$\begingroup\$ Don't forget to mark your answer as accepted, so the question doesn't keep bouncing around unresolved. \$\endgroup\$
    – DMGregory
    Oct 8, 2016 at 17:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .