Using Path2Ds in Platformer Character Movement

Godot Version

Godot 4.4

Question

I’m coding player movement and I’m trying to make a celeste style dash. I want it to go in all 8 cardinal directions and not move the player in any other direction when that is happening. I thought a path2D would work for that but I have no idea how to set it up. I’d like it to be in the player scene because I have to put that same player in other scenes but I don’t know how that would work. I understand that the path follow needs to be a child of the path 2D but if I have 8 paths where would I put the pathfollow2D? then where would I structure that mess of paths and pathfollows onto the player. I guess they can be a child but I don’t know if that would cause problems with transforming the root node.
P.S. If you’ve seen my previous showcase post yes this is for an update to Summit.

A Path2D is probably the wrong route. I’d bet you can set the velocity to one of eight directions and ignore player input for the duration of the dash.

The way the game is coded now it does use velocities and I just don’t like the way it works. Because of the way the velocity’s get added it causes some odd bugs where you can jump and dash at the same time for an added boost and dashing up doesn’t work while falling.

Try setting = the velocity instead of adding +=

That worked. I’m surprised that such a simple and obvious thing made such a big difference. Thank you!

edit:
I’m having trouble now with the changing the velocity.y for some reason, even if the velocity.x = 1000 and velocity.y = -1000 using the 1000 on velocity.x doesn’t move the player as far as using velocity.y = -1000 shifts the player up. I don’t know if this is because I constantly have a force acting upon the player because I have gravity as a variable opposed to using the built in gravity or something else.

It may work best if you avoid applying all other forces while the dash is operating

I’ve gotten rid of gravity while dashing so now no other forces are acting upon it and all that did was strengthen the dash upward. the friction is disabled when dashing and the gravity is too. for some reason the dashing still acts weirdly with upwards dashes sending you into the stratosphere and sideways dashes moving you a a bit.

edit:
I got it working. The gravity takes time to slow down the player so it takes a while and prolongs the dash beyond what it should be.