- Home /
Why is my raycast messy
So I have this detection script on the main camera in a first person game that uses raycasting. The problem is it only works if you're looking at objects a certain way, it only works for a door sized box collider if view square on, and another paper sized collider if the ray hits the very edge.
if (Physics.Raycast(transform.position, transform.forward, out hit, interactionDistance) && hit.collider.gameObject.CompareTag("Pickup") )
{
Debug.DrawRay(transform.position, transform.forward, Color.red, 0.2f);
Debug.Log("Hit");
instructions.enabled = true;
instructionText.enabled = true;
instructionText.text = "Press 'E' to pick up"; }
Answer by shachar1like · Aug 31, 2019 at 08:23 AM
I think the 0.2f means it will draw it for 0.2 seconds. am new to this myself...,am new to this myself but in the debug.drawray, I think the 0.2f means it will draw the line for 0.2 seconds
Your answer
Follow this Question
Related Questions
raycast is slowing down computer... 2 Answers
Can't find a clone object with RayCast? [Solved] 2 Answers
How can I differentiate between colliding with an object or its child? 1 Answer
raycast in direction of movement key down 2 Answers
RaycastHit returns object without collider, in wrong layer 1 Answer