3
\$\begingroup\$

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?

\$\endgroup\$
1
  • \$\begingroup\$ uhm... wot.... But yeah, i think you would be best creating a "Normal Plane" controller, then modifying this so it never falls out the world You know, when you stop moving. i cant think of a simply way to achieve what you want though. \$\endgroup\$
    – Ryan white
    Aug 17, 2016 at 8:56

1 Answer 1

-1
\$\begingroup\$

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.

\$\endgroup\$
4
  • 2
    \$\begingroup\$ You can do that, but then you shouldn't use Rigidbodies, because these can behave very weird when you manipulate the transform directly. No rigidbodies also means you can't use the Unity physics engine to handle movement after a collision. \$\endgroup\$
    – Philipp
    Aug 19, 2016 at 11:01
  • \$\begingroup\$ @philipp Any idea what I should use instead? I do need collisions so it seems I've taken the wrong direction entirely :(. \$\endgroup\$
    – moran
    Aug 21, 2016 at 3:37
  • 3
    \$\begingroup\$ You should do what the tutorials say: Use the standard physics engine but ramp up the drag parameters. That will give you a more arcade-like feel. When it is too slow (is it really? Have you tested it?) you will have to write your own newtonian physics, implementing only the features you need. \$\endgroup\$
    – Philipp
    Aug 21, 2016 at 10:10
  • \$\begingroup\$ @philipp I've pretty much got it working now. I'm using a FixedUpdate and the Rigidbody.AddForce, but putting the drag on the rigid body in the inspector rather than in the script itself, which is much simpler than what the tutorials were doing. \$\endgroup\$
    – moran
    Aug 21, 2016 at 10:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .