I’m making a dungeon crawler RPG type game, with custom characters. And I’ve
ran into an issue with the attacking animation.
What do I want to achieve?
I have a custom character, and I want to make it so when it slashes, it moves forward a bit.
Sorta like this:
What is the issue?
Whenever the character moves forward, the animation cancels.
Example:
This is what the animation looks like:
What solutions have I tried so far?
I’ve tried VectorForce, BodyVelocity, CFrame, and ApplyImpulse. All do the same thing.
Here is my code:
if not (humanoid.MoveDirection.Magnitude > 0) then
local Force = 50
char.PrimaryPart:ApplyImpulse(char.PrimaryPart.CFrame.LookVector * char.PrimaryPart.AssemblyMass * Force)
end
local punchAnimation = humanoid.Animator:LoadAnimation(script:FindFirstChild("Punch" .. Combo))
punchAnimation:Play()
I also tested this with a normal Roblox character and it works fine.
Here’s the video:
Here’s my custom character’s parts and Humanoid properties:
The attack animation priority is Action.
while the walk animation priority is Movement.
Here’s the walk animation script if you’re interested:
local idleAnim = script.Parent.Animations:WaitForChild("IdleNEW")
local idleAnimTrack = humanoid.Animator:LoadAnimation(idleAnim)
humanoid.Running:Connect(function(speed)
if speed > 0 and speed < 17 then
if not walkAnimTrack.IsPlaying then
stopAllAnimations()
walkAnimTrack:Play()
end
elseif speed > 0 and speed > 17 then
if not RunAnimTrack.IsPlaying then
stopAllAnimations()
RunAnimTrack:Play()
end
else
if walkAnimTrack.isPlaying then
stopAllAnimations()
idleAnimTrack:Play()
end
end
end)
function stopAllAnimations()
for i,v in pairs(humanoid:GetPlayingAnimationTracks()) do
v:Stop()
end
end