If Statement Help

Photo Above: Anyone knows why the Debug.DrawRay or Debug.Log(“if ran”) isn’t displaying a message when the code is running?

First,the best, would be to embed code to your question not a photo. Second, your code shows “it works 000” and none of the other 3 debugs?

Wow. Not only is the code not embedded in the post but it has been included with a picture taken on a phone not a screenshot and then uploaded to Google Drive instead of being uploaded straight to the forum. That is one heck of an effort to post an image and even then, it is not even the full code.

Apologies if this sounds like a rant, I just find it funny.

1 Like

I guess he was just typing from his phone. Anyway, the Debug.DrawRay is probably showing but you are not seeing it cause is completely perpendicular to the camera. Try to view it from the scene window instead of the game view.

Edit: BTW if you are just showing it when you shoot a “bullet” it will only appear for just a frame, so… no ray. Move it to Update() and check only the Debug.Log() when you shoot. I imagine you are seeing The Debug.Log(“Raycast Detected”), right?

Debug.DrawRay also takes magnitude into account, so your ray will only be one meter long. Try using the direction of transform.forward * 10.0f

Yeah only shows the “it works 000”

Yeah I’ll try that once I get back on Unity.

is “raycast detected” printed?

you may want to try GetComponentInParent if you have nested colliders