Moving and shooting
The cube could already move. Now I want it to wrap around to the other side.
To get the effect I want, the cube gets teleported from one side to the other when reaching the edge of the camera.
I want the player in view at all times, so up and down movement is limited.
Can’t have a space shooter without shooting
By creating a simple capsule and scaling down I have created a bullet of sorts.
In unity making a prefab out of something is pretty easy, just dragging it from the hierarchy into the project view does the trick. Using a prefab I can shoot more than one time.
Having made the bullet I now have to get it to move. I create a script for what will become the laser. It’s pretty simple really, all it does is move upwards, constantly.
By destroying the lasers when they have traveled outside the camera view, I prevent them from staying around and eating resources.
For this simple scene, I’m not worried about resources, but since I don’t need them anymore I destroy them.
Now I just need something to shoot at 😄