Search Unity

Disable player input in third person when Canvas / UI is shown

Discussion in 'Scripting' started by l3m35, Aug 26, 2021.

  1. l3m35

    l3m35

    Joined:
    Apr 1, 2019
    Posts:
    5
    Hello everyone, first post here. I've been playing around with Unity for around two months, so not many knowledge...

    I was building something using the Starter Assets - Third Person Character Controller Pack https://assetstore.unity.com/packag...sets-third-person-character-controller-196526

    My idea is a simple adventure, where the player interact with NPCs to get dialogues. It's using the new input system and Cinemachine; I was able to implement the dialogue UI (following instructions of this lesson
    ), it's working the way I need.

    But I don't know how to disable the player inputs – like camera and character control – when the UI is called, so player can control the UI instead (press space or so to jump dialogues, or select options using mouse or D-pad, etc).

    Any directions? If you need additional info, let me know. Thank you.
     
  2. Rotary-Heart

    Rotary-Heart

    Joined:
    Dec 18, 2012
    Posts:
    813
    Sounds like you are using Unity PlayerInput, you can disable your input by calling
    Code (CSharp):
    1. input.actions.Disable();
    Where input is a reference to the GameObiect PlayerInput component.
     
    l3m35 likes this.
  3. Qian98

    Qian98

    Joined:
    Nov 9, 2022
    Posts:
    1
    Time.timescale=0;

    game pause when ui showup