Need help with Vectors

I have a side step mechanic like in beatrun.

It works almost well except when I change the way the player is facing, it won’t recognize that and still go in the direction its already pre planned to do.

Now if I were to use lookvector or rightvector it will, but it will update in the direction I turn rather then continue in the direction you flicked.

Code:

local flickDirection

	if stateManager.GetStates("FlickLeft") then
		if not flickDirection then
			flickDirection = Vector3.new(-1, 0, 0)
		end

		local newVelocity = flickDirection * 50 + Vector3.new(0, Torso.Velocity.Y, 0)
		Torso.Velocity = newVelocity

		Humanoid.WalkSpeed = 30
		isAccelerating = false

	elseif stateManager.GetStates("FlickRight") then

		if not flickDirection then
			flickDirection = Vector3.new(1, 0, 0)
		end

		local newVelocity = flickDirection * 50 + Vector3.new(0, Torso.Velocity.Y, 0)
		Torso.Velocity = newVelocity

		Humanoid.WalkSpeed = 30
		isAccelerating = false
	end

Video:

You need to constantly update the velocity so it keeps moving you towards the direction you want. also, you need to do this for flick direction:

flickDirection = HumanoidRootPart.CFrame.RightVector -- for right
flickDirection = HumanoidRootPart.CFrame.RightVector * -1 -- for left

CFrame.new(Torso.CFrame):PointToWorldSpace(velocity) should translate the dash velocity relative to the torso (or you could use hmr)

Like I said, if I use anything relative to the parts on the player it will go in the direction continously. So if I do side step left or right it will go in those directions but not at a fixed direction, it will update as a turn.

Lets say I flick towards the pole, it should continue to go to the pole no matter which way I turn after flicking (which my script already does), but using the velocity relative to the player, if I were to turn away from the pole the velocity will be applied to the direction change instead of still going towards the pole.

The issue I’m running into here is that I can’t figure out way for it to go at a fixed direction relative to the players torso without the velocity updating the direction the torso is while in the flicking state.

this is me using youre methods. It updates the velocity based on the torso. Not what I want.

Yes indeed it knows now what direction the torso is facing but it still doesn’t go in a fixed direction.

just get the direction one time when the player starts dashing

then, you could just not update the flick direction

1 Like