I’m stuck on how to make a 3D Starfield that I can fly through to give a sense of motion. I’ve got so far a working skybox, but the particle systems that aren’t doing what I want.
In a 2D top down space game, one could easily make 2 layers of stars moving at different speeds to create a parallax effect. I was trying to do something similar, but after a certain distance the particles wouldn’t draw anymore.
What I’ve tried:
sphere emit around the player, emit source moves, but everything is world simulated; this emitted too much when I’m not moving fast, and too little when I am.
3 planes (well, short but wide boxes) of different distances, but the furthest one gets clipped from draw distance. And it isn’t far enough to give that sense of parallax.
I’m new to Unity and I’m trying to make a simple 3D (2.5D) Spaceship Game as a way to learn Unity and its components. Please help
Here’s an example of the scene (don’t mind the coloured stars… just checking which systems I can see):
Well, stars really aren’t close enough together for you to see them move very much as your ship moves, so realism is already out the window.
Keeping star density in 3D as you move is a daunting undertaking. I honestly don’t know of a solution other than maintaining them yourself - on startup, generate stars within a sphere around player. When a star leaves the sphere, fade it out and fade another in on the opposite side.
Something like this untested mess:
var starsMax : int = 200;
var starDistance : float = 100;
private var stars : List.< Vector3 >();
private var tx : Transform;
private var starDistSqr : float;
function Start() {
for ( var i : int = 0; i < starsMax; i++ ) {
stars.Add(Random.insideUnitSphere * starDistance);
}
starDistSqr = starDistance*starDistance; // to allow use of the faster sqrMagnitude property
tx = transform;
}
function Update() {
for ( var i : int = 0; i < starsMax; i++ ) {
if ( (stars *- tx.position).sqrMagnitude > starDistSqr ) {*
stars = (tx.position-stars_).normalized * starDistance; } // display star somehow - SpriteManager can make this a reasonably painless operation Debug.DrawLine(stars+Vector3.up,stars*-Vector3.up,Color.white); Debug.DrawLine(stars+Vector3.right,stars-Vector3.right,Color.white); Debug.DrawLine(stars+Vector3.forward,stars-Vector3.forward,Color.white); } }*_