Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Disabling Player Motion

Discussion in 'Scripting' started by TheA-Team, Nov 13, 2017.

  1. TheA-Team

    TheA-Team

    Joined:
    Aug 22, 2017
    Posts:
    23
    Hey Guys, I have a simple question that I cannot answer myself because of my little knowledge of Unity. My player controller is straight from
    , although a few modification to variables. (also posted below) I am working on a dialogue system (
    ) and everything works fine except for locking movement because the tutorial uses the first person controller where I am clearly using third-person, so player.movementSettings.direction doesnt work. (my code is also posted below) Anyway, Is there any way to disable and rein-able the movement? thanks in advance!
     

    Attached Files:

  2. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    A couple of ways come to mind immediately.
    1) you could have a bool to say it's enabled/disabled and simply check that at the top of your update function; unless the code to enable/disable it is in the same update function, then you should put the check after that :)
    2) in a similar construct, you could enable/disable the script component when you want it on/off. When the script component is disabled, Update() and other Unity functions won't run.

    If there's something else not covered, please expand your question with a little more information.
     
  3. TheA-Team

    TheA-Team

    Joined:
    Aug 22, 2017
    Posts:
    23
    this sounds logical and will probably work, if I knew how to do it or the specific functions. Thanks for the help though, you gave me a great idea to try!
     
    Last edited: Nov 13, 2017