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
1
Question by chronicfail · Jun 15, 2013 at 10:00 AM · camerarenderenemiesvisionoffscreen

Off Screen Render of Camera As Enemy Vision

I am making the enemy code for a first person shooter and have worked out a reasonable system for enemy vision using triggers. It detects players within the trigger volumes and then raycasts to check if there is not a collider in between them.

This works, but it means that objects without colliders like some of the foliage in the game do not work as cover. I was thinking that a better system for my game would be if the enemies had cameras attached, which render (offscreen) all non-player objects in one colour and the player in another. If there was any player-colour objects visible it would try and kill the player. This would work based on renderers instead of colliders so would be more accurate.

However, I don't know if this is even possible, or how to do it. If anyone does know anything that could help, please tell me.

Comment
Add comment · Show 12
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 whydoidoit · Jun 15, 2013 at 10:28 AM 0
Share

Sounds very very slow to me. I think you will need colliders on all cover opportunities.

avatar image chronicfail · Jun 15, 2013 at 10:37 AM 0
Share

I have heard some games use this as the system for detecting bullet hits, and because most of the time in a render is taken up by shading, and this would use solid colour, that wouldn't be as slow. Also it would only do this when there is a player in the vision trigger- sorry, I should have explained- this is just replacing the raycasting to look for cover.

avatar image whydoidoit · Jun 15, 2013 at 10:49 AM 0
Share

Depends on your platform, but you are going to ask the graphics card to transform every vertex and interpolate every pixel so you are still doing a lot of shading (just not much calculation in the fragment shader). Also you'd have all of the pre-culling etc.

avatar image whydoidoit · Jun 15, 2013 at 10:52 AM 0
Share

You also have to then find that pixel color in the resulting render texture - another slow process. It might work if you had very low resolution textures, but I wouldn't be holding out that much hope of it giving real performance. Normally you cover search by having properly annotated objects.

Also I guess you'd have to check for more than one pixel - seeing a single pixel of an enemy isn't actually likely to break cover. Seeing an enemy behind some leaves would probably represent reasonable s$$anonymous$$lth cover even though technically many pixels of the target are visible, the pattern of the leaves means that they are not recognisable.

avatar image chronicfail · Jun 15, 2013 at 10:55 AM 0
Share

I don't know much about shaders, but what if it used unlit or even no shader at all so that there is no time spent lighting? Plus it would only render in a certain distance. What if it only ran every ten frames or so when the player is in the field of view trigger?

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by Coderdood · Jun 18, 2013 at 06:58 PM

While certainly a novel solution to your problem to use an off screen render, and I admit that its interesting. I think it would probably be an unworkable / slow solution.

I would suggest to simply use colliders. As whydoidoit suggested you can make colliders triggers, or on a different layer. See Physics.IgnoreLayerCollision .

Its possible you could implement a custom solution using a "ProvidesCover" type component to each cover object and some sort of "CoverSystem" manager type object that can determine whether a specific spot is visible from a specific angle / distance / etc. But the chances of it being better or faster than the built in Unity raycast system is pretty slim. Especially since, unless you have force field type objects, any collision object is automatically cover so a custom cover system would have to replicate all the work of tracking / checking collisions objects.

Comment
Add comment · Show 1 · 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
avatar image chronicfail · Jun 19, 2013 at 07:53 AM 1
Share

Thank you, I tried using layers and IgnoreLayerCollision, and it works, with no problems at all.

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

17 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

Related Questions

rendering things in order 0 Answers

Glow effect - alpha channel ignored to some specific android device 0 Answers

Is it possible to render mesh when it's pivot out of camera bounds? 0 Answers

gameObject.renderer.isVisible = false for one frame after activation 1 Answer

Let camera render the scene just one time 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