2D Asteroids Style Game

Hi guys,

I’m planning to duplicate the ship movement that is found in the Asteroids game.

I am trying to make a 2D game where the character flies and I want it to behave like the ship in that game

Is there any where i can look for reference or how to build this type of movement into my game?

Thanks

That’s really trivial.
You simply keep a velocity vector by which you translate the ship on every update (multiply it by Time.deltaTime to be framerate independant).
Then, you’ll rotate the ship left or right around the camera-facing axis while the respective arrow key is pressed.
Finally, while thrusting, you add the forward vector of the ship, multiplied by some constant and by Time.deltaTime, to your velocity vector.

That’s it

there are some tutorial/example projects in the asset store. void framework comes to mind.

I should have mentioned I’m not very good at coding. I can understand what I need to do but implementing this isn’t my strong point. So far I can move the object up and to the right. Left and down doesn’t seem to work.

Thanks but I’d rather not pay $50 to look at some code

first. its not only the code but assets, prefabs etc. so a good start for a similar project in any case.
second. you asked for a reference. not for a free one.
this is the best starting point you can get. if you refuse to use it good luck. it will take you some time to collect the required knowledge step by step and requires helpfull people in the forums. don’t know if you can always rely on that.

I have managed to get my movement and I have come across a weird problem. Whenever my object collides with another, say a wall, it just spins out of control and continues to just spin.

Does this mean I have to limit what axis it can move on? If not, how do I get fix this problem?

I made a game like this (Asteroids 2.5D) a earlier this year.

Be sure to lock the 3rd dimension axis of your spaceship and items in the game on the rigid body. By this, I mean if you are using the X and Y axis for your game, then lock everything on the Z-axis so they can’t move in that dimension (towards or away from camera).

When dealing with spaceship movement and propulsion in 2D, I simply just applied forward force to the ship when [up arrow] was pressed or held down to propel it forward. The [left arrow] and [right arrow] just simply rotated the ship along it’s 3rd dimensional vertical axis.

One of my earlier builds as an example: http://dl.dropboxusercontent.com/u/91852/Asteroids%202.5D/index.html

3dbuzz has a tutorial on making a game like this

This video shows you how to do it.

Looks like you just attach the script to the ship object.

It is not my video.

Ive managed to get my character moving. Thank you for everyone’s input :smile: