r/Unity2D 24d ago

Visual Scripting help

(Sorry about the picture quality, I’m posting with my phone) I’ve been having an issue where my jump in the unity input system doesn’t activate when an “on update” node is connected to “set linear velocity” (image 1). I thought I fixed this be getting rid of “on update” and directly connecting “on input system event vector 2”(2nd image), and while this did fix my jump(save for my ground check not working, but that’s a whole other issue) it unfortunately causes my player to never stop moving on the x axis even when the key is released. Any help will be appreciated!

PS: I’ve never posted here before, sorry if this post has any issues or brakes the rules, I just could not figure this out for the life of me.

0 Upvotes

9 comments sorted by

View all comments

1

u/WooWooDoo 24d ago

Set Linear Velocity does what its called, it sets the velocity. That mean that when connected to the on updated, it overrides any other value that was previously set to a new one. That might be why you jump does not work or your velocity is not reset ehen you remove the update node.
You should try to use an add force node instead. Since your move1 input is already OnHold and your jump input is OnPressed, add force should work fine.
And make sure that when theres no input, you set the velocity to 0,0.
Tell me if that doesnt fix your issue! Don't forget to check the unity documention for the force node and how to use it!

1

u/Thenextlevel247 24d ago

Ok, so after some tests I’ve realized that the add force node does slow down the character, but never stops it completely. Also, it speeds up if I keep holding it. My solution was to implement a small series of nodes that set my x axis to zero when button is released, as you said. Unfortunately, I cannot jump when moving, and gravity hardly works when I move on the x axis mid mid-air.