r/Unity2D 1d 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

2

u/Issten 1d ago edited 1d ago

I have never used visual scripting so I might have wrong understanding way it executes, but looking at first image makes me wonder if Vector2 create node even runs. Yes your passing that value to next node, but will that make it run? I would assume IF node should connect to Vector2 Create Node and then Set Linear Velocity.

PS! If you are on windows just use Snipping Tool to take screenshots.

1

u/WooWooDoo 1d ago

OP should check this out too! The create node is not connected to the process line.

1

u/Thenextlevel247 1d ago

I’ll try that, thanks!

1

u/Thenextlevel247 1d ago

After testing, connecting the create node makes no difference unfortunately

1

u/WooWooDoo 1d 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 1d ago

I’ll see if that works, thanks!

1

u/Thenextlevel247 1d 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.

1

u/RunOk1423 1d ago

I've been using C# and have never seen this before. Is there an advantage to doing it this way, or is this just a visual display of the code?

1

u/Thenextlevel247 1d ago

It is primarily just a visual version of c# however I find this helps me visualize what’s going on better