Search Unity

First person controller from standard assets and stop moving when game over

Discussion in 'Editor & General Support' started by AdamW99, Jan 5, 2021.

  1. AdamW99

    AdamW99

    Joined:
    Nov 10, 2020
    Posts:
    5
    I have a question about first person controller, which i have from standard assets. How can i stop moving this controller after game over condition in my game?
    That is after my health points are 0 i want to stay in one place and cant walk, jump, etc, and next i will set my game-over screen. I think that i must set something in script and function death() but how to do that with fpc controller?

    Thanks for help!
     
  2. FrankenCreations

    FrankenCreations

    Joined:
    Jun 14, 2017
    Posts:
    326
    I'm not the best at this, I don't know it all. There's likely someone around who will pop up with more robust and elegant solutions but since it's been nearly a full day and no one has I'll get you started.

    The simplest way is to use Time.timescale in a c# script. Set it to 0 to stop everything, set it to 1 for normal speed or set it anywhere else for slow motion or fast motion. This will get you started but is not the best solution as it stops everything. For instance if you have some cinemachine camera motion you want to keep moving or other objects that still need to move they will also stop. Once you get deeper into it you'll want to figure out a better way.

    From one noob to another.....Good Luck
     
    Joe-Censored likes this.
  3. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    I haven't used this controller, but the first thing I'd try is just disabling the component.

    The above timescale suggestion is a good idea too, especially if there are a variety of things you want to stop moving, and not just this controller. For example, you may want enemy NPC's to stop moving as well, or objects affected by physics to stop falling, etc.