Landing Animation

Hello. I have an animation for a character. The character is programmed to make a jumping animation and then be launched into the sky. When the character returns back to the ground, it is supposed to play a landing animation. The problem is, is when the character lands back on the ground it takes an extra half second before it is rendered on the ground therefor distorting the animation and making it look unrealistic.

For example, it would land, wait about half a second, and then play the landing animation. I am aware that the form of animating I am using(CFrame Animating) is delayed slightly but I believe there is a more efficient way to run the code for the animation at a more convenient time.

I have tried using Humanoid.FloorMaterial to detect whether or not the character has landed on anything except air. And I have also tried using HumanoidRootPart.Velocity.Magnitude to detect when the velocity has come to a neutral state.

Current Code:

function jump()
	isMoving = true
	humanoid.WalkSpeed = 0
	character:MoveTo(hrp.Position + Vector3.new(0, 10, 0))
	
	hrp.Velocity = hrp.CFrame.LookVector * 250 + Vector3.new(0, 125, 0)
	
	
	
	repeat wait()
		
		print("Still In Air")	
		
	until humanoid.FloorMaterial ~= Enum.Material.Air or math.floor(hrp.Velocity.Magnitude) == 0
	
	**Animation Code Here**
	
	wait(0.68)
	isMoving = false
	humanoid.WalkSpeed = 11
	return true
end

1 Like

Is this a server script? If so, that’s your issue. (play the animation on the client first, then tell the server to replicate it to everyone)
Also, try using task.wait() for more speed. (task.wait() is 60 fps, wait() is 30)

Yes, the script for the animation is run on the server side. However, since it is a MainModule require() script; which means it is a script written for the purpose of being used in multiple different games, it INEVITABLY has to be CFrame animated.

I assume you know but just in case, standard animations made in one game cannot be used in another game owned by a different person or group; making animations unusable.

Should the animation start sometime before the player hits the ground, or right as they hit the ground?

You could try using either Raycast directly down, or use a Part.Touched event. It depends on what you’re going for.

I agree with you. Playing the animation before the player hits the ground is a great idea. Only thing is the Part.Touched event would give no better than the output of Humanoid.FloorMaterial, meaning this wouldn’t be necessary.

But I like the raycasting idea. How would I go about doing this?

1 Like

You can use this Humanoid state type.

if humanoid:GetState() == Enum.HumanoidStateType.Landed then
    --// Run code here \\--
end

This checks if they have landed.

since this needs to be serverside, you’ll have to predict when they’ll land by raycasting or simulating a second ahead of movements and start playing the landing animation at (time of landing - the user’s ping)

1 Like