Search Unity

Sonic the hedgehog upside down loop. Stylized Local gravity?

Discussion in 'Scripting' started by NinjaTaco, Sep 21, 2010.

  1. NinjaTaco

    NinjaTaco

    Joined:
    Apr 21, 2009
    Posts:
    175
    I experimented with the physics briefly.. By itself.. It does seem possible to have an object with enough velocity to just go through an upside down loop. But the speed seems problematic.. It goes through sometimes. I guess this is because once an object goes so fast. It's calculating the physics on a frame to frame basis and the object passes through before proper collisions can be calculated.

    But with that said.. To get those speeds the object ends up moving too fast for the player to see what is happening.. So what I'm wondering is.. If there is a way to do a localized stylized gravity..

    if player speed is greater than X... The character will stick to the surface and the model reorient itself based on the normals. Otherwise the player will just falloff or something..
     
  2. npsf3000

    npsf3000

    Joined:
    Sep 19, 2010
    Posts:
    3,830
    To decide whether you are inside a loop-the-loop, you could just put a big box over the whole construct and use its trigger.

    To do your stylized force, figure out if the car is touching the road (ray-cast), and then apply your own custom 'down-force'.

    TBH - I would try a universal custom down-force first, before doing anything too special.

    ------

    Don't know if this will work, but it's an idea to muck around with.
     
  3. Ullukai

    Ullukai

    Joined:
    Aug 24, 2010
    Posts:
    746
    or add a constant force on your player controller... there was a setting in mine there
     
  4. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    If you apply a down force will that cause the car to be pushed away from the top of the loop when it gets up there, or drawn towards it?
     
  5. jeffro11

    jeffro11

    Joined:
    Jan 7, 2010
    Posts:
    185
    The car should be drawn towards the top of the loop if your going fast enough, if not, you should start applying "real" gravity again. Also it would be good to check your local rotation to see if your above 90 degrees (to the right side of the loop, assuming your doing a left to right sonic esque movement) to start applying your custom gravity.
     
  6. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Then jumped on the forum the moment it didn't magically work how you wanted. Thats the problem, physics aren't something you can be brief with, its all about testing, testing...

    Docs are helpful: http://unity3d.com/support/documentation/Components/class-Rigidbody.html

    In particular:

    In addition to the continuous dynamic flag, play with the mass, more mass will help carry it round the loop.
     
    Last edited: Nov 10, 2010