Quantcast
Channel: Questions in topic: "issue"
Viewing all articles
Browse latest Browse all 827

Raycast not Detecting Colliders

$
0
0
Raycast does not seem to be hitting colliders. My walls are in their own layer but putting them in the default layer did not change anything. The Debug.DrawRay() and Debug.Log(hi1.transform.name) are not returning anything but I'm sure the Shoot() method is being invoked because of my other Debug.Logs. public class ShootP1 : MonoBehaviour { public GameObject Shooter; // Update is called once per frame void Update () { if (Input.GetKeyDown("r")) { Shoot(); //Debug.Log("Pressed"); } } void Shoot() { RaycastHit hit1; //Debug.Log("shot"); if (Physics.Raycast(Shooter.transform.position, Shooter.transform.forward, out hit1, 1000)) { Debug.DrawRay(Shooter.transform.position, Shooter.transform.forward, Color.cyan); Debug.Log(hit1.transform.name); } }

Viewing all articles
Browse latest Browse all 827

Trending Articles



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