Quantcast
Channel: Questions in topic: "ios"
Viewing all articles
Browse latest Browse all 4709

Raycast Hit not working

$
0
0
Hello We made a script that toggles the camera between different iTween paths when you click objects on mobile But the Recast isn't reliable with multiple buttons I even tagged the clickable objects Here's script: Thanks public class ControlSampleRayA : MonoBehaviour { //NOTE: You have to TAG your Collider with "trigger_a" public int pathNo=0; public int path2Return2 =0; public float percentage=0f; float returnPercentage; public string debugLog=""; public string trigger = "trigger_a"; Camera camera; FlythroughCamera_Mod aController; public Collider coll; private RaycastHit hit; // Use this for initialization void Start () { camera = Camera.main; aController= camera.GetComponent(); coll = GetComponent(); } void Update() { if (Input.touchCount > 0 && Input.GetTouch (0).phase == TouchPhase.Began) { Ray ray = Camera.main.ScreenPointToRay (Input.GetTouch (0).position); RaycastHit hit; if (coll.Raycast (ray, out hit, 100.0f)) { if (hit.collider.gameObject.tag == trigger) { if (aController.whichPath != pathNo){ returnPercentage=aController.percentage; Debug.Log (debugLog+" "+ aController.whichPath+" "+ pathNo+" "+ returnPercentage); aController.ToggleToPath (pathNo, newPercentage:percentage); } else { Debug.Log (debugLog+" "+ aController.whichPath+" "+ pathNo+ " "+ returnPercentage ); aController.ToggleToPath (path2Return2,newPercentage:returnPercentage); } } } } } }

Viewing all articles
Browse latest Browse all 4709

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>