Search Unity

Path Follow in Planet Gravity

Discussion in 'Scripting' started by Paykoman, Oct 21, 2016.

  1. Paykoman

    Paykoman

    Joined:
    Jun 26, 2014
    Posts:
    500
    Hi guys im trying something that involves enemies follow a path in a planet gravity, right now i make the player gravity work just fine but i cant get how to handle the path follow part, can anyone give me some info or tips if possible? Ty
     
  2. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    You'll need to provide more information.

    To simulate a body free falling in gravity you simply add a force towards the centre of mass of the system.

    To have a body follow a specific path under gravity is more complex. You need to determine the path to follow, and then add the appropriate steering forces to keep the body on the path. Investigate a PID controller as an option to help with this.
     
  3. Paykoman

    Paykoman

    Joined:
    Jun 26, 2014
    Posts:
    500
    I'm trying something like a tower defense in a planet so the enemies need follow the road path as usual but in a planet format.. i try find some information and there aren't really much arround.. i try investigate wt u said, appreciate

    just one thing, if i hv a script that attracte the enemies to the planet and have a sequence os empty game objects as path point to follow since its already with gravity to center they will move properly?

    PS: It work, just hv some kind of little jump but i hv to test with gravity script :)
     
    Last edited: Oct 21, 2016
  4. Zaflis

    Zaflis

    Joined:
    May 26, 2014
    Posts:
    438
    Could be easier if the enemies aren't actually affected by gravity at all. Just a scripted path to follow. But i don't know the game so.
     
  5. Paykoman

    Paykoman

    Joined:
    Jun 26, 2014
    Posts:
    500
    Thats basicaly wt i do, but i see a bit of jump when they change direction in certain ones...