however when i angle my camera above my character the look vector faces downward. this results in very low dash velocity but when I angle it facing my character horizontally it dashes normally:
thats not the issue, and i did multiply by vector.new(1,0,1) so that the Y value is excluded so the player doesnt fly when they dash, its just that the x and z get really low values when you look above your character and that causes the dash to be really slow. how do i make these values the same as when you angle your camera horizontally so the dash is consistent and normal.
I wouldn’t use the Camera’s LookVector. Use the RightVector (you can achieve a “LeftVector” by multiplying the RightVector by -1) of the HumanoidRootPart for a sideways dash and LookVector for a forwards dash.
I didnt use humanoidrootpart because if your arms are facing the camera then the player would dash forward if it was a sideways dash. and sideways if it was a forward dash. from the cameras perspective.
Your issue is that the movement isn’t relative to the Cameras direction. You can achieve this by making the character face in the Cameras direction using the Camera LookVector then apply your force.
PrimaryPart.CFrame = CFrame.lookAt(PrimaryPart.CFrame, cameraLookVector * Vector3.new(1,0,1))
force.Force = PrimaryPart.CFrame.LookVector -- Player is now looking at where the camera is, so this will apply a forwards force
i dont know how to make the player face the camera before the dash. but if thats not the way and theres still a way with camera lookvector i will do it
Once you get the LookVector, you’re going to have to remove the Y axis like @Tom_atoes suggested. But you’ll have to take another step; the x and z axis has to add up to 1(to achieve constant velocity for every dash).
Step 1
Get the look vector, let’s say the look vector was Vector3.new(0.5, 0.2, 0.6).
Step 2
Remove the y axis:
local newVector = Vector3.new(0.5, 0, 0.6)
Step 3
Add up the x and y axis, then divide 1 by that number:
local adjustAmount = 1 / (newVector.X + newVector.Y) -- 0.90909090909
Step 4
You would then multiply the x and y axis by adjustAmount:
local newVector = camera.CFrame.LookVector -- Vector3.new(0.5, 0, 0.6)
local adjustAmount = 1 / (newVector.X + newVector.Y) -- 0.90909090909
local adjustedVector = Vector3.new(newVector.X * adjustAmount, 0, newVector.Z * adjustAmount)
--[[
Make the player start dashing in the adjustedVectors direction,
adjustedVectors direction is moving at 1 stud per unit time, so
multiply it by x to increase it x times
--]]
BodyVelocity.Velocity = adjustedVector * x