Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

How to create a ghost imitate last player mouvement

Discussion in '2D' started by Leandro95, Mar 19, 2015.

  1. Leandro95

    Leandro95

    Joined:
    Mar 18, 2015
    Posts:
    16
    Like a ghost replay on drive game (in Mario kart when u play against your ghost) if can help me with some idea or better with some code,script it would be well.
     
  2. proandrius

    proandrius

    Unity Technologies

    Joined:
    Dec 4, 2012
    Posts:
    544
    Just every couple of frames (depends how detailed you want) save character position to the List and then make ghost move to every point that is that list from start to finish.
     
  3. Leandro95

    Leandro95

    Joined:
    Mar 18, 2015
    Posts:
    16
    When my player die i reload the application level, i need to make the List an static variable ?Can i got a little example because i already try to do this but make some bug , should i use Math.Lerp to interolation the postion vector of my list
     
  4. proandrius

    proandrius

    Unity Technologies

    Joined:
    Dec 4, 2012
    Posts:
    544
    There are multiple ways to save your List, you can even write to file or add DontDestroyOnLoad or even using static. As for moving it, you can use transform.Translate or Lerp, depends how you want to move it.
     
  5. Leandro95

    Leandro95

    Joined:
    Mar 18, 2015
    Posts:
    16
    OK i got it will try it thx