- Home /
Help with FOV script
void CheckForWalls()
{
Collider[] wallsInRadius = Physics.OverlapSphere(transform.position, wallRadius, runnableWall);
for (int i = 0; i < wallsInRadius.Length; i++)
{
Transform wall = wallsInRadius[i].transform;
dirToWall = (wall.position - transform.position).normalized;
if (Vector3.Angle(transform.forward, dirToWall) < checkAngle / 2)
{
if (Physics.Raycast(transform.position, dirToWall, VisibleReach, runnableWall))
{
Debug.Log("WALL IN RADIUS");
}
else { Debug.Log("WALL NOT IN RADIUS"); }
}
}
if (!isWallInRadius) StopWallrun();
if (isWallInRadius) canDoubleJump = true;
}
Why does it not Debug.Log if the wall is not in radius?
What do you mean "not in radius" You get wallsInRadius by doing OverlapSphere. If they are not in the defined radius, or in the right layer, then the for loop is not run and no Debug is ever called.
Even if you overlap some walls then you check also the checkAngle in if (Vector3.Angle(transform.forward, dirToWall) < checkAngle / 2)
If this returns false nothing is showing in debug either.
If your code ever reaches the Raycast then one of the two Debugs are always called (only some application exception might prevent this but this should be noticeable.
$$anonymous$$gestion: Add more Debugs.Log's to follow how the execution is done + log also variable values so you can check what they are. You can also use add breakpoints to your code in VS to debug what's happening.
Answer by VoidPhoenix96 · Jan 23, 2021 at 02:33 AM
Because you never declare your function. Basically void CheckForWalls()
is just storing code for use later. What you need to do is run this but in void Update()
that should work. You could also just write CheckForWalls();
in update to stay organized.
Your answer
Follow this Question
Related Questions
Wrote a script to pick up objects detected by raycast, but they are dropping unexpectedly. 1 Answer
Is this way of making a raycast correct 2 Answers
Mouse Over Questions 1 Answer
¿Why Raycast sometimes don't collide with rigidbody (plus collider)? 0 Answers
Debug.DrawRay doesn't show up, but gizmos are on and duration is specified. 1 Answer