Physics for space game

Updated on October 23, 2014 in [A] Unity Scripting
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
4 on October 23, 2014

Hey people 🙂 I just want to try creating a scene where I can fly around in a ship but also have a planet that you can land on. Dont really know where to start with the physics. The ship controls I created so far dont use a rigidbody. When I tried implementing it I would just spin out of control the moment I touched a planet. I suppose its because I unchecked use gravity. If anyone has made anything similar would you please share some knowledge or maybe a good tutorial.

I want to achieve something like in these videos:
http://www.youtube.com/watch?v=1MwbVvSHuI0

http://www.youtube.com/watch?v=Cngr6JUfkD4&list=UUG95E6DEFV91Af_fD3KKepQ

  • Liked by
Reply
1 on October 23, 2014

Are you working in 3d or 2d?

Master
on October 23, 2014

In 3d

Show more replies
  • Liked by
Reply
Cancel
1 on October 23, 2014

for the ship, here’s some suggestions:
Use a rigidbody.
For movement use AddForce and AddRelativeForce
Set up a max velocity (aka, if(velocity.x > 5) velocity = 5)

You’re gonna want to do some serious Vector studying. Figure out how to make so the ship figures out the current angle to the center of the planet once it enters a certain range (have a trigger collider around the planet for that), then have a force that pushes the ship towards the center of the planet always.
Relevant:
http://answers.unity3d.com/questions/13639/how-do-i-make-a-small-planet-with-gravitational-pu.html

Master
on October 23, 2014

Thanks, will try this 🙂

Show more replies
  • Liked by
Reply
Cancel