- Home /
Question about distant objects
Given a space scene where there can be ships of various sizes, and more than one planet.
The ships can be at varying distances. Should I have three cameras?
One for the ships
One for any planet I might possibly approach.
One for distant planets (the planets will be some distance from each other, of course. I would think that you would draw all planets as distant, except the one you are closest to.)
Does this sound like the right approach?
If I have a scene (think an x3 system, or possibly eve) where the ships can be very small (star trek shuttlecraft size) to VERY large (think huge carrier, mile or two long), should I use 4 cameras? One for near ships, one for far, BIG ships, one for near planets..one for far planets....
One other questions...how to handle transitions. Will each object need to handle switching to be drawn by a different camera, based on distance from the player?
Or is that overkill? Anyone with experience with this type of situation have any suggestions?
(Edit: I noticed that Unity's scene view seems to be able to properly draw just about anythin, near or far. How is that?)
Answer by Random Indie · May 25, 2010 at 02:38 AM
The system i'm using right now for this type of thng uses two spaces.
The first space, celestial, has planets, moons, stars etc and all objects are tiny comparison say ships in the editor. It has its own camera that has greater depth than anything else.
I have another layer, local, that contains ships, asteroids, and stations. This layer is like a normal scene for any shooter.
To make everything look right I have the celstial camera move and rotate with the local camer, it rotates the same but moves slower.
This all looks weird in the editor but in game it looks fine. For ships far away I used sprite to represent them.
Doing it this way I can fit an entire 'galaxy' into one scen and just load/unload what is needed locally on the fly.
It sounds weird but it works well. If that didn't make sense I can clear it up.
Oh, lights can be layer specific so you can avoid weirdness by flying by the stars light in world space. When in game it looks like the ship is nowhere near the star.
Very interesting responses. So, if your ships could approach the planets, and at the same time be distant...how would you handle this?
Not sure what you mean. Do you mean that 'in game' you approach a planet but 'in editor' you're far away?
If so, I have it set up so that the celestial camera has control over certain things like colliding with a planet. If it gets to close to a planet then it fires off a warning that you're entering an atmosphere or are getting too close to a planet (if an atmosphere is absent). I haven't decided if I should have the player automatically slow down before a planetary collision or if I should blow up the ship if they get too close.
Either way, since the celestial camera and the player have references to eachother it's easy to have one affect the other.
If however you mean 'in editor' the player is close to a planet but 'in game' the plAyer is far away, nothing happens, the ship can fly through planets asthey don't have collider on them, just triggers.
I can post a few screenshots tomorrow if you like, might make it more clear as I'm not sure I'm making a tonne of sense at times.
An idea I was toying with is having layer based collisions so thatthe local and celestial objects don't accidentally interact unless I force them to.
Something I forgot to mention earlier, the player never gets more than 5000 units away from the origin. If they try, the plAyer is moved back to the origin and the local gameobject (contains everything close by) is move the same amount and direction, that way floating point errors don't show up near the player. For instance, if a station is at 0 when the player hits 5000, the player goes to 0 and the station goes to -5000. I don't really care about physics errors far from the player because they won't be seen.
Answer by Chris Masterton · May 10, 2010 at 10:28 PM
I don't think this will give you the results you think it will. The final composite image is going to have no depth consistency. The player wont know the difference between a near and a far ship.
Is this problem because ships & planets that are far away are not drawing at all? Or are drawing so small they can't be seen? Either way, when objects are too far away to be represented by geometry you can use a 2d icon/sprite instead.
You may be able to put this into the LOD of the model (not sure, havent done this in Unity but in other systems you can) - so when its really far away it switches to the sprite. Otherwise you will need to do the switch manually.
For example say you have your camera and a ship in your scene. The dashes are representing distance from the camera to the object.
c---->Full 3D Ship
c--------->Lower polygon 3D Ship
c--------------->Distance of the far clip plane, nothing is drawn beyond here
c------------------------>Ship will not be drawn, its passed the clip.
In the last case, thats when you want to swap the 3d model of the ship with a small 2d sprite. That will give the user something to click on/view.
c---->Full 3D Ship
c--------->Lower polygon 3D Ship
c--------------->Distance of the far clip plane
c->Far away ship drawn as a camera facing sprite/billboard/icon.
(Unity's scene viewer (if I remember correctly) has an incredibly long far clip plane, which you probably don't have setup for the game camera. If this is the case then objects that are past the clip plane will not be drawn at all. Its better for performance to have as short a far clip plane as possible.)
So for planets, or a sun which are far away, I'd just need to use sprites for them until they get close enough? Would someone normally use render to texture to generate this image?
Please ignore the previous comment/question, it really is a seperate issue. But, regarding your response, my concern is that if my primary camera far plane is too close, large ships in the distance won't draw correctly (there will be a loss of Z precision), or at all. But, I'm used to using the default camera, with a far plane of 1000. I might be able to bump it to 10000, increase my near plane, and still have plenty of precision for all of my ships.
Answer by equalsequals · May 24, 2010 at 11:55 PM
Last summer my team and I put together a game where the bulk of it took place in space.
My personal preference for building space scenes is to have a very deep far clipping plane and to actually take the planets and bake them into the sky box. If you're in space, you're most likely not going to be close enough to planets to be zooming by them as it just doesn't look realistic. Therefore baking stuff like that into the sky box is actually quite beneficial to performance and realism.
Cheers,
==
Your answer
Follow this Question
Related Questions
How to make first-person work in zero-G with planets? 1 Answer
Would anyone mind telling me about memory size of blank camera built in APK? 0 Answers
(CLOSED) Plane Failing to Render When Camera is Switched Until Scene is Reloaded?! 0 Answers
Can I use Real Scale Space Objects With Colliders? 1 Answer
Character Camera Movement/ShooterGameCamera On planet with Faux 0 Answers