Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I create a backflip animation where the character actually jumps backwards?

Creating a stationary backflip is no problem. Getting the player to actually jump backwards, however, has caused some difficulty.

My first attempt was to make the animation stationary and then use Velocity to move the character back. Although both the 'bump back' and the animation worked fine on their own, putting the two together caused problems. Setting the velocity of the torso caused the animation to stop mid-way through (as soon as the Velocity was changed), and not finish playing.

My second attempt was to build the movement into the animation, but this didn't work either. Animations are only created around a HumanoidRootPart, so while all the other parts of my character moved, the HumanoidRootPart did not. This caused both the camera to stay in the same position and the character to snap back to the HumanoidRootPart after the animation was finished.

Although all my code is functional, neither method worked. Do you know of a new, better one?

EDIT

Code:

local plr = game.Players.LocalPlayer
	repeat wait() until plr.Character
local chr = plr.Character
local hum = chr:WaitForChild("Humanoid")
local root = chr:WaitForChild("HumanoidRootPart")

local mouse = plr:GetMouse()
local anim = workspace:WaitForChild("Animation")
local canPlay = true

mouse.KeyDown:connect(function(key)
	if key:lower() == "q" and canPlay then
		canPlay = false
		local animTrack = hum:LoadAnimation(anim)
		local bt = Instance.new("BodyThrust",root)
		bt.force = Vector3.new(0,0,4000)
		animTrack:Play()
		wait(0.4)--Anim. time
		bt:Destroy()
		wait(1)
		canPlay = true
	end
end)

4 comments

0

If you are using animations, you can use key frames and either BodyPositions or CFrame.

0

Was there a script involved for this animation? Or was the jump animation's ID replaced by this one?

0

Strange how it wouldn't work when BodyMovers are involved. I just made a simple backflip animation that, upon pressing 'q', the player jumps and the animation plays. This involves a BodyThrust inside of the HumanoidRootPart, and everything worked perfectly fine.

0

My BodyThrust's force is 'Vector3.new(0, 0, 4000).'

1 answer

My suggestion: You may create a BodyForce inside the HumanoidRootPart, since it is stationary while the animation plays.

You can set the force of it to the HumanoidRootPart's lookVector, then negate it to get a force the opposite direction of the front face.

BodyForce.force = -(HumanoidRootPart.CFrame.lookVector * 100)
-- Something like this.

This works ideally in a condition where the animation does a stationary backflip, rather than:

  • a tuck and have a BodyMover object/ RotVelocity/ Velocity do all the rotation work.

  • a backflip animation that moves the character back, excluding the HumanoidRootPart.

I hope this helps.

5 comments

0

Unfortunately both a BodyForce and a BodyVelocity caused the animation to quit playing.

0

Try and set the priority of the animation to 'Action' if it isn't.

0

It is.

0

The script played the animation every time I pressed q. The script functions perfectly.

0

The BodyThrust works better than BodyForce, but the force is not powerful enough to move the player back. It does when you jump, but I don't want the player to have to jump, as I want no extra height. I'll edit my question with my code.

This discussion is preserved as it was. New answers, comments, and votes are closed.