Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question How to stop player movement when attacking

Discussion in 'Input System' started by Draugrlord, Jul 31, 2023.

  1. Draugrlord

    Draugrlord

    Joined:
    Oct 1, 2021
    Posts:
    30
    I've been searching for the past couple of days on how to figure this problem out but so far, I've not gotten anywhere. I am wanting to make it to where the player stops moving when attacking, like how Link in BoTW will stop all movement when you begin swinging your weapon around. The closet I've gotten to achieving this is disabling player input when I trigger my attack but then I am unable to figure out how to reactivate the input and be able to move again. I've tried using the OnEnable() to reactivate the input, but I'm using this wrong because once I go and test the game, I'm suddenly back to being able to move when attacking and the OnDisable() stops working. I would put up my code but currently I'm simply using the Start Assets - Third Person Asset Controller from the Asset Store, I don't have my own code yet as I am also learning how to use the new input system. I have looked at the documentation that talks about disabling and enabling the action maps but I'm also not able to get my head wrapped around that as well so any help at al to point me in the right direction would be greatly appreciated.