A general question on Rendering

I am new to Unity and I was just curious if there is a way to script the game to render certain objects in the world based on a defined FOV of character not the FOV of the camera.

For example, 3rd person camera following your character. I am curious is some objects are rendered based on the FOV of the char.

This is more of a discussion question, so there isn’t a need to give me script examples (unless you really want too) because I am not on a computer that can use a Unity3d for testing.

Thanks ahead of time

I fear that makes no sense …
FoV defines how objects are transformed into the view space (and which ones are rendered at all), as such the FoV is either on the camera or no FoV at all.

If it isn’t a FoV then, you perhaps need to explain in detail what you want to achieve effect wise.

hmm

Ok, let me try again (its late).

3rd person camera, normally the game renders everything even objects behind the char that the camera still sees. What I want to know is that can I determine what is visually rendered based on what is in front of the char, not based on what is in front of the camera?

Yes, you can do that. You can control whether an object will (potentially) be rendered by enabling/disabling its associated renderer, e.g.:

renderer.enabled = false; // 'Hide' this object

And/or you can fade objects in and out using alpha blending.

As for determining what objects are visible to the player, how to do that depends on what exactly you want the ‘rules’ to be, but at its simplest it just involves some simple vector math. (If you need more details, perhaps you could explain how you want the visibility test to work.)

you say potentially to be able to enable/disable the renderer with script. Do tell about the restrictions.

Though, the alpha blending sounds like a cleaner/smoother way to do it – any general things to look out for using that method.

In general i want only some objects to be adjusted for visibility – like badguys – other objects like obstacles would never need to be made invisible. This would be about the extent of my rules for this general question.

I have attached a really awesome MS Paint picture I made. The black circle would be the char, the gray area would be the zone in which objects would be visible and outside that would not be visible.

Thanks for the help so far.

438761--15243--$render.JPG

By ‘objects that will potentially be rendered’, I just mean any object with a visual attached to it. (I say ‘potentially’ because such objects generally won’t be rendered if they’re not visible to the camera.)

I don’t have the documentation open right now, but I think there’s a ‘vector angle’ function that you could use for this. You’d want to compute the (unsigned) angle between the player’s forward vector and the vector from the player’s position to the target’s position, and see if it’s below some threshold. (There are other ways to do it, but they’re basically variations on that same theme.)

lol - wierd posting mistake

When I get aroudn to messing with this I will have some direction, thanks for the help – I appreciate it.

Be warned though, there will likely be forum posts with more specific help on this topic :smile: