Asteroids style movement?

I’m looking to replicate the floaty movement found in the arcade classic Asteroids, but I’m not sure how I should start. Any thoughts? Eventually I’d like to add a little flare to the movement by making the ship (the Pixel Ship from the movement example) bank as it turns while moving.

Ha! I just did this one from scratch. The screen wrap is the hard part, really, but the movement’s pretty simple. Create a blueprint, add a sphere component as root, which obeys physics, then a static mesh component parented to that, which doesn’t. You’ll set the rotation on the SM and get the forward vector from it, which you’ll use to Add Impulse to the sphere component. Use “Is Input Key Down” for the spinning and forward thrust. I added something like .02 on each Event Tick for rotation and considerably more than than that for thrust.

As for the ship banking, that’s a little harder, but not much. You’ll need the difference of the sphere component forward vector and the thrust direction derived from the ship’s Z rotation. That can be used to apply bank rotation to the ship model.

Screen wrapping is tough, but really, all you have to do is get the viewport size (player controller->getViewportSize I think, the bP’s not in front of me right now), then test to see if your ship goes past it. Then you can set the position to be whatever it is minus the size amount of the screen in that direction.

Hope this helps
-john

Any way you could provide some screen shots of what you did in blueprint for the movement? I’m trying to follow along but I must be missing something.

Agreed…

I’m missing it too. Any help is much appreciated.

I done it all with thrusters and physics body for spaceship.
one forward thruster, that is in 0,0,0 relative to spaceship
and 2 turning thrusters that are 50 units ahead and behind ship, both facing to the side.

To accelerate i apply positive value to forward thruster, to decelerate negative. Some slight automation here (depends on how floaty movment you want) is to add damping when above certain velocity. and damp a bit when you slow down (ie push backwards). Also damping when player nearly stopped to zero the speed.

Now for turning you apply positive and negative forces to turning thrusters. Automation that help player: when player tries to turn opposite than current spaceship angular speed, add angular damping. Luckily physics bodies have max angular speed.

You can also add strafing: apply same direction force to both turning thrusters.

Now few more tips about spaceship that uses physics:
add physics constraint to hold ship in one surface. Free both movement planes, restrict Z. Then for angular free only one responsible for turning.
to make life easier add physical collision mesh, only this mesh should have physics emulation enabled, it should be box or some regular shape mesh (so you know where center of mass is). Make this mesh invisible.
Then on top of that physical mesh you can put your visuals meshes and things, they should have physics and collision turned off

I took a different approach to the wrap around in my Asteroids clone that I am currently doing … and that was to create 4 ‘walls’ (trigger volumes) and when the objects go past it wraps around to the other side plus or minus to miss the opposite wall. This was really just to see if it could be done that way … Using getViewPortSize sounds like a lot easier approach though! (still learning)

Yep thats pretty much what I am doing as well … The thruster component makes this a lot easier … Lots of Asteroid clones in the works … we should make a thread and compare!

I did asteroids on planet orbit, vector math on sphere was pain in da butt.
But then we realized that fighting stuff around planet while its very cool visually it limits gameplay in several ways. Also there was huge problem with random camera spin around poles.
I still have that version, it was quite cool. We even got some unintentional effects like collioris and herding all asteroids around some orbit in big stream.
Since we gone for flat space everything is easier.
I can post some movie from one of those versions.

Sounds like Super Stardust to me … Which I actually quite like … But it is pretty mental …

Yes after we made basic gameplay we found out that superstardust is asteroids on ball.
It did totally not work for us because mobile phones sometimes are tiny, gameplay was terrible on tiny planet.
Well more like moving pawn was very inaccurate on tiny screen, adding autoaim in arcade game defies reason to play it.