Search Unity

trouble with gravity, please help me!!

Discussion in 'Scripting' started by T.Lourenco, Feb 1, 2011.

  1. T.Lourenco

    T.Lourenco

    Joined:
    Jan 23, 2011
    Posts:
    15
    hi guys!

    well I m working in a game, its like a race in frist person.
    But now I have a problem, I want to run in a loop, or kind of roller coaster , mario galaxy....
    I had seen some codes here and i ve tried but it doesnt work because when start to go up it fall out! so at moment a have any code!

    so any ideas?

    I have no clue, and plus I am not good in codes!

    please!!! help me!!

    thanks!
     
  2. T.Lourenco

    T.Lourenco

    Joined:
    Jan 23, 2011
    Posts:
    15
    37 minutes...

    no ideas! no help!:(
     
  3. Cameron_SM

    Cameron_SM

    Joined:
    Jun 1, 2009
    Posts:
    915
    raycast down and transform gravity vector to the normal of the surface you hit.
     
  4. Jesse Anders

    Jesse Anders

    Joined:
    Apr 5, 2008
    Posts:
    2,857
    Hehe...the forums move fast, but they don't always move that fast ;)

    Anyway, in addition to Cameron's suggestion, I'd suggest searching the forums and Unity Answers for 'mario galaxy', as this topic is discussed fairly frequently.
     
  5. JRavey

    JRavey

    Joined:
    May 12, 2009
    Posts:
    2,377
    You'll need to make a ton of special zones if you want loops, but the planet style is pretty easy.
     
  6. T.Lourenco

    T.Lourenco

    Joined:
    Jan 23, 2011
    Posts:
    15
    jesse I ve tried the Mario galaxy one and many other codes, but all of them, when the frist person move to go up and spin like roller coaster it fall out!

    and another thing I m studying Unity less than one month!

    and before this i know 0 of programming (honestly)

    my thing is graphics....But I would like so much to solve it !

    so i try different codes and it doesn t work, and i dont know why!

    thanks again!
     
  7. JRavey

    JRavey

    Joined:
    May 12, 2009
    Posts:
    2,377
    When you are in a loop, you are pushed away from the center of it, right? So you'd probably reverse gravity and push away from the center and align the character to point at the middle.
     
  8. T.Lourenco

    T.Lourenco

    Joined:
    Jan 23, 2011
    Posts:
    15
    JRavey the game it is not walking on a planet surface....is like a race in frist person, and part of this race there is this kind of looping .

    Every things are ready but just missing this main point of the game for me, because it a very simple mechanics, but it driving me crazy!
     
  9. Cameron_SM

    Cameron_SM

    Joined:
    Jun 1, 2009
    Posts:
    915
    I made a hover car racing game prototype that could handle loops without needing "special zones". Took a few days of code massaging but ended up with something very similar to f-zero like mechanics.

    No clue where that project is now though, that was a few years ago, but a single raycast down to align the gravity to the surface normal worked well. From memory I was smoothing the gravity vector over time and had limits on how much the surface normal could change before I'd start to align with it. I think I also had to transform some of the velocity to keep everything stable.
     
    Last edited: Feb 2, 2011
  10. T.Lourenco

    T.Lourenco

    Joined:
    Jan 23, 2011
    Posts:
    15
    I didnt want to give up, i already tried all the codes i ve seen about it but it doesnt work!, i ll check what Jravey said.

    the graphics are sooooo nice! prefessional thing, but the script jesusssss How I would love to know about programing a another level!

    and all so a have to bear the jokes.....programming ist not for girls! hehehheheh

    I need the code, if u guys find anything send me! PLEASEEEEEEEE.

    IAM KIND OF PERSON WHO DOESNT GIVE UP TILL A GET IT!

    CHEERS!!

    iam here studying thsi gravity thing! hehehheh
     
  11. T.Lourenco

    T.Lourenco

    Joined:
    Jan 23, 2011
    Posts:
    15
    oooh cameron !!!

    come on,,, PUSH IN YOU MIND this code i am sure u ll get it! heheh

    please!
     
  12. JRavey

    JRavey

    Joined:
    May 12, 2009
    Posts:
    2,377
    Oh, that is clever if the track is accommodating, Cameron. Rotate it appropriately, give it a local gravity and you're set.