I am trying to make a dash/ jump feature in my game where I leap in a certain direction and do a spiral in the direction that the camera is facing. I also want the player to face that direction while jumping, but my animation for the spiral part is flat:
This is what it looks like whenever I do the leap::
As of right now, I have attempted to change the orientation of the HumanoidRootPart to face the same way as my camera, but that just makes my character rotate in every single direction. I have also tried using the TweenService to do basically the same thing and it ended up the same.
I’m mostly wondering if this would even be possible, because as of right now my best solution is just remaking the same animation a few times and running a different animation depending on which direction the camera is facing, but that wouldn’t look as nice. Thank you in advance!
I think you’re doing great. Try disabling AutoRotate Inside the Humanoid during this animation so that WASD doesn’t rotate the humanoid root until you land (or get out of the dash)
Thank you for your reply! Unfortunately, I’m still struggling to get it to work. Here’s the code I have for it so far:
local function createVelocity(part, velocitySize, duration, camera)
local Attachment = Instance.new("Attachment", part)
local LV = Instance.new("LinearVelocity", Attachment)
LV.VelocityConstraintMode = Enum.VelocityConstraintMode.Line
LV.MaxForce = 2000 * part.AssemblyMass
LV.LineVelocity = velocitySize
LV.LineDirection = part.CFrame.LookVector
if camera then
LV.LineDirection = workspace.CurrentCamera.CFrame.LookVector
end
LV.Attachment0 = Attachment
game.Debris:AddItem(Attachment, duration)
end
function Movement.leap(player)
animationTrack = player.Character.Humanoid.Animator:LoadAnimation(bulletJump)
if playerState == "" and player.Character.HumanoidRootPart then
playerState = "leap"
animationTrack:Play()
-- This is the main part I'm struggling with
local hrp = player.Character.HumanoidRootPart
local cameraVector = workspace.CurrentCamera.CFrame.LookVector
hrp.Transparency = 0
player.Character.Humanoid.AutoRotate = false
hrp.CFrame = CFrame.lookAlong(hrp.Position, cameraVector)
----------
createVelocity(hrp, 150, .5, true)
player.Character.Humanoid.AutoRotate = true
task.wait(.75)
playerState = ""
end
end
The issue that I’m seeing is that the HumanoidRootPart doesn’t rotate on its x-axis, which is what I need it to do more than anything
Oh! I see the issue. Try using PlatformStand. It puts the Humanoid in a Physics State.
I also had to find a way to keep the player Rotated in that direction. It works, but I’m not sure if this is what you wanted. I also set the animation to loop. I’m not sure how it’ll look.
local function createVelocity(part, velocitySize, duration, camera)
local Attachment = Instance.new("Attachment", part)
local LV = Instance.new("LinearVelocity", Attachment)
LV.VelocityConstraintMode = Enum.VelocityConstraintMode.Line
LV.MaxForce = 2000 * part.AssemblyMass
LV.LineVelocity = velocitySize
LV.LineDirection = part.CFrame.LookVector
if camera then
LV.LineDirection = workspace.CurrentCamera.CFrame.LookVector
end
LV.Attachment0 = Attachment
game.Debris:AddItem(Attachment, duration)
end
local animationTrack = player.Character.Humanoid.Animator:LoadAnimation(bulletJump) --Load this outside so it doesn't have to load every time
animationTrack.Looped = true
function Movement.leap(player)
if playerState == "" and player.Character.HumanoidRootPart then
playerState = "leap"
animationTrack:Play()
local hrp = player.Character.HumanoidRootPart
local cameraVector = workspace.CurrentCamera.CFrame.LookVector
hrp.Transparency = 0
player.Character.Humanoid.AutoRotate = false
player.Character.Humanoid.PlatformStand = true
----------
local attachment = Instance.new("Attachment",hrp)
attachment.Name = "TempAlignmentAtt"
local b = Instance.new("AlignOrientation",hrp)
b.AlignType = Enum.AlignType.AllAxes
b.Mode = Enum.OrientationAlignmentMode.OneAttachment
b.RigidityEnabled = true
b.Attachment0 = attachment
b.CFrame = CFrame.lookAlong(hrp.Position, cameraVector)
createVelocity(hrp, 150, .2, true)
task.wait(.2)
local params = RaycastParams.new()
params.FilterType = Enum.RaycastFilterType.Exclude
params.FilterDescendantsInstances = {player.Character}
local function cast()
local ray = game.Workspace:Raycast(hrp.Position, Vector3.new(0,-1,0) * 5,params)
return ray
end
repeat cameraVector = workspace.CurrentCamera.CFrame.LookVector b.CFrame = CFrame.lookAlong(hrp.Position, cameraVector) task.wait(.1) until cast() --this is scum, but it works so ARHHHH
attachment:Destroy()
b:Destroy()
animationTrack:Stop()
player.Character.Humanoid.AutoRotate = true
player.Character.Humanoid.PlatformStand = false
task.wait(.75)
playerState = ""
end
end
EDIT: I had to add back the Animations and PlayerState
Thank you so much! I was unaware that your solution even existed, so I’ll definitely be looking into it more to understand it better. You were a huge help, thanks again!