1. Help us improve the editor usability and artist workflows. Join our discussion to provide your feedback.
    Dismiss Notice
  2. We're looking for feedback on Unity Starter Kits! Let us know what you’d like.
    Dismiss Notice
  3. We’re giving 2017.1 beta testers a chance to win t-shirts and a Nintendo Switch. Read more on the blog.
    Dismiss Notice
  4. We want to know how you learned Unity! Help us by taking this quick survey and have a chance at a $25 gift card
    Dismiss Notice
  5. Are you an artist or level designer going to Unite Europe? Join our roundtables there to discuss artist features.
    Dismiss Notice
  6. Unity 5.6 is now released.
    Dismiss Notice
  7. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice

'Super Mario Galaxy' style gravity simulation

Discussion in 'Scripting' started by jmarrington, Jan 18, 2009.

  1. jmarrington

    jmarrington

    Joined:
    Jan 18, 2009
    Posts:
    4
    'lo all, new Unity 3D convert here. I'm relatively new to games design, I'm currently studying traditional comp-sci and multimedia.

    What I'd like to do is build my first attempt at a 3D game on an implausibly small planetoid, similar to the the many-small-planetoids approach used in Super Mario Galaxy. Since the player will be moving all the way around the circumference of the game world, the concept of 'down' can't simply be a negative acceleration along the Y axis, but rather an acceleration towards a particular point (the centre of the planetoid).

    So, my guess is that the one way to simulate this (particularly as I only intend to have a single planetoid for this game at least) would be to have a game-world level script that modifies the X/Y/Z acceleration of objects based on their positioning in reference to the centre point I define.

    Has anyone else attempted this already? Can I use the Physics.gravity property for this? Are there any bugbears I should look out for (especially if I start having multiple rigidbodies falling and hitting each other at the same time, like a rock-slide or similar)?

    Nice to meet you all. I'm looking forward to learning from this community :)
     
  2. Charles Hinshaw

    Charles Hinshaw

    Joined:
    Feb 6, 2008
    Posts:
    1,070
  3. KlaRo115

    KlaRo115

    Joined:
    Feb 24, 2006
    Posts:
    674
  4. jmarrington

    jmarrington

    Joined:
    Jan 18, 2009
    Posts:
    4
    Thanks, all :)

    Both of these are much easier than the trig script I was tinkering with.

    (note to self: search function exists for a reason. Sorry.)
     
  5. nickavv

    nickavv

    Joined:
    Aug 2, 2006
    Posts:
    1,801
    Using info from those topics I made a single planet gravity demo. I also made a neat camera script that keeps you in focus, so it looks like the planet under you is rotating.

    I can post it later, not on my Mac right now.
     
  6. KlaRo115

    KlaRo115

    Joined:
    Feb 24, 2006
    Posts:
    674
    Yes, good idea:
    Rotating the planet, not the player! :D
     
  7. nickavv

    nickavv

    Joined:
    Aug 2, 2006
    Posts:
    1,801
    Well, I physically rotate the player, but the camera follows the player so it appears that he's still rightside-up. It gives a very cool effect, I think. ;P
     
  8. jmarrington

    jmarrington

    Joined:
    Jan 18, 2009
    Posts:
    4
    Yes please!

    That sort of of effect would work very well for my game's perspective I think. Could you post the script?
     
  9. nickavv

    nickavv

    Joined:
    Aug 2, 2006
    Posts:
    1,801
  10. jmarrington

    jmarrington

    Joined:
    Jan 18, 2009
    Posts:
    4
    Thanks :) That looks pretty awesome running around a big sphere. Beautiful curved horizon.
     
  11. nickavv

    nickavv

    Joined:
    Aug 2, 2006
    Posts:
    1,801
    :D No problem.
     
  12. maxwelldoggums

    maxwelldoggums

    Joined:
    Sep 8, 2008
    Posts:
    157
    What I would do is create a standard constant force whose vector varies depending on the position of the object, basically point a ray at the center of the "planet" and apply it as the gravity.