How to code a non-newtonian spaceship control script?
I'm working on a simple 3D space combat game, and I've decided to go with simplified physics over proper newtonian motion, similar to the space sim Oolite, and more 'arcade' style games. I basically want my ships to move how spacecraft do in Star Wars. This is what I'm trying to achieve specifically; ability to rotate along each axis, and with solely forward motion relative to the spacecraft. In the case of impacts and collisions I want to spacecraft to move under normal physics, but for any rotation/velocity incurred by the collision to quickly bleed off. I can find a lot of tutorials that show how to achieve this kind of flight by setting angular drag and such in a standard aircraft controller. This seems like it is a waste of resources however, since you are using the drag equations to cancel out the newtonian thrust equations. Since I'm aiming for hundreds of ships in a single battle I need to keep things as efficient as possible. So is there a simpler, more efficient way to have this kind of controller?
I found out how to do this, so I’ll put it up in case anyone else is trying to do the same.
Unity has a function called Transform.Rotate which can be used to rotate a game object around its own axis. I used this for roll, pitch, and yaw. The I used the similar Transform.Translate for forward motion.
- Database Administration Tutorials
- Programming Tutorials & IT News
- Linux & DevOps World
- Entertainment & General News
- Games & eSport