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 GiantsDomain · Jun 30, 2015 at 10:33 AM · vision

How to create 'sections' in a vision cone?

Hi,

I'm currently working on a project where the enemies have vision cones and the design I have is that a single vision cone has three sections to it. The full length of the vision cone is 15 metres and split in three like so; 0-5, 5-10, 10-15.

My vision works at the moment by using a cone shaped mesh collider and when triggered by the player the enemy will chase. I was wondering how I go about splitting my vision cone up into 3 'sections'? I have a feeling that I need to use Vector3.Distance (I'm unsure of this route however) or I could make 3 individual vision cones (which would be the long way round probably).

Any help/direction would be appreciated.

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Hellium · Jun 30, 2015 at 10:44 AM

If you use Vector3.distance, your vision cones will have a rounded base (wich may be what you want). It's not a bad solution but the script may be a mess quickly if you have very specific behaviour according to the section of the vision cone.

Otherwise, if you use a trigger as vision cone, splitting it in 3 may be a good solution. Each section will have it's own script with a different behaviour. Then, you could use an abstract class VisionCone and three sub classes as follow :

 public abstract class VisionCone : MonoBehaviour
 {
     // Drag and drop the closest vision cone here
     public ClosesVisionCone ClosestVisionCone ;

     // Drag and drop the middle vision cone here
     public MiddleVisionCone MiddleVisionCone  ;

     // Drag and drop the farestvision cone here
     public FarestVisionCone FarestVisionCone ;

     private void OnTriggerEnter(Collider other)
     {
         Foo(other) ;
     }
 
     protected abstract void Foo(Collider other) ;
 }


 public class ClosestVisionCone : VisionCone 
 {    
     protected override void Foo(Collider other)
     {
         Debug.Log("Closest") ;
     }
 }


 public class MiddleVisionCone : VisionCone 
 {    
     protected override void Foo(Collider other)
     {
         Debug.Log("Middle") ;
     }
 }


 public class FarestVisionCone : VisionCone 
 {    
     protected override void Foo(Collider other)
     {
         Debug.Log("Farest") ;
     }
 }

Then, you will have to drag and drop the appropriate script on the appropriate section of your vision cone.

Splitting an object in 3D is not that hard. In Blender for example, you have the Loop Subdivide tool :

http://www.blender.org/manual/modeling/meshes/editing/subdividing/loop_subdivide.html?highlight=loop

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

lighting/vision 0 Answers

How to make an objects texture what a camera is seeing 2 Answers

Enemy VISION range? Help! 0 Answers

Increase Field of vision of Enemy over time 1 Answer

How to make a Fog of War on TILE-based map? 2 Answers


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