Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

K-hunter87

4
Posts
1
Topics
A member registered Apr 28, 2023

Recent community posts

I have a variable that locks the movement. If the player presses and holds a move button while locked, the code makes the velocity (0,0). When the variable unlocks it, its keeping the velocity at (0,0) until the button is released. Then the movement works the way it should. I want the player to start moving the second the animation finishes, without having to manually release the movement buttons. 

Instead of changing the rigidbody's velocity, is there a way to disable the input system's action for WASD? Or should I make a separate action map without WASD for when movement is supposed to be frozen and then switch back?

Yea, it's unity. My bad for not posting that. >_<;;

(1 edit)

I am very new to coding, please bare with me if I post something wrong. 

The player is able manually pick up and hold an item. While the pick up animation is playing, the move controls are temporarily set to zero velocity, and then set back to the OnMove controls. If the player holds any of the move buttons before the WaitForSeconds has switched control back, the player will not move until they release the key(s) they are holding.

I would like to force the release of the movement buttons in the script so the player doesn't have to release the button to start moving. Totally a quality of life fix but a necessary one. 

Thanks in advance!!!

(I can post more code if needed. Not 100% certain on how to post it, it doesn't seem to be as straight forward as posting an image or table, and it took me a while to find the "```" method. )


-Kyle


```
void OnMove(InputValue value)
     {
         if (canMove)
         {
             moveInput = value.Get<vector2>();
         }
         else
         {
             rb.velocity = new Vector2(0, 0);
         }
     }
     void OnJump(InputValue value)
     {
        if (!feetCollider.IsTouchingLayers(LayerMask.GetMask("Ground"))) { return; }
         
        if(value.isPressed)
        {
             rb.velocity += new Vector2(0f, jumpSpeed);
        }
        anim.SetBool("isJumping", inAir);
     }
     void OnFire()
     {
         if (!playerHasHorizontalSpeed)
         {
             anim.SetTrigger("bend");
             canMove = false;
             StartCoroutine(WaitForBendAnim());
         }
     }
     IEnumerator WaitForBendAnim()
     {
         yield return new WaitForSeconds(0.6666666f);
         canMove = true;
     }
 }

Ditto, I choose you!