Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by OcerEXE · Jan 22, 2021 at 07:11 PM · raycastscripting beginnerraycastingdebuggingfov

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?

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image CodesCove · Jan 23, 2021 at 08:21 AM 0
Share

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.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

170 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges