Skydiving System HOW TO

This is what I have right now and is really bad. :confused:

Why isnt it changing the fall anim to the second anim even though I stopped moving? 
local plr = game.Players.LocalPlayer

chr = plr.Character or plr.CharacterAdded:Wait()

local RunService = game:GetService("RunService")

local function updateSkydiveAnim()
	if chr then
		if chr.Humanoid.MoveDirection.Magnitude > 0 then
			chr.Animate.fall.FallAnim.AnimationId = "rbxassetid://6214558611"
		end

		if chr.Humanoid.MoveDirection.Magnitude <= 0 then
			chr.Animate.fall.FallAnim.AnimationId = "rbxassetid://6214532059"
		end
	end
end

-- Update the effect on every single frame.
RunService.RenderStepped:Connect(updateSkydiveAnim)

https://gyazo.com/4b876977b23036cd6007fec18e9b4e8a

I don’t know if this is close to the thing you want to do

1 Like

Yes, I alredy have that, but what I am trying to achieve is wheb the character moves in a direction while falling, I want it to player a diving animation. But if they dont move around and just stay still, then I want it to be a free fall. As you can see, I made a code above and the free fall works but when i move in a direction it plays the animation but then when I still stay, it still plays the diving animation. You can take a look at the gyoza gif.

The invalid link does not work

https://gyazo.com/4b876977b23036cd6007fec18e9b4e8a

What I understood after translation is that you want to do the same thing

I know you don’t want to kill the player

Just remove humanoid.Health = 0

For the sake of movement, you have to remove this

humanoid.WalkSpeed = 0

Canceling a player’s death can not change anything in the course of the program

You can do whatever you want with the player while in the air or upon reaching the ground

The idea is simple

Depend on the distance between the player and the point of fall

Determine the distance to do whatever you want from the animation or something else

I think you missunderstood me, I am not trying to make fall damage.

I don’t know about your code, but I didn’t use an update loop like you do with renderstepped, I trigger the dive animations based on the movedirection like:

character.Humanoid:GetPropertyChangedSignal(“MoveDirection”):Connect(function()

I use that to play and stop my ‘action’ animations which override the default animations, I did not change any default animations.

1 Like

Know that you want to do freefall

A falling player from a high place enables you to control the player

While in the air and upon reaching the ground, you do what you want to do

What is important to you is the control if you know that the player is in the air or on the ground

I have a landing parachute form if I find time I will send you a video

Alright, I will try that. Thank You.

Landing parachute

This is what I am talking about. If it is far from what you want to do then I apologize for wasting your time

If the player jumps and is in the air

I calculate the distance between the player and the falling point

Do whatever I want while the player is in the air

The player can use Parachute

If the player reaches the ground and is not using a Parachute, he will die

Change what you want to change and do what you want, it is important to know how the program works

This code when placed inside a Script in ServerScriptService

game:GetService('Players').PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local root = character:WaitForChild("HumanoidRootPart")
local humanoid = character:WaitForChild("Humanoid")
local animation	= script:WaitForChild("Animation")	
local animate = character:WaitForChild("Animate")		
local EndJump = 50 --Put the distance you want		
local FallDeath = false	
local heartbeat = nil		
local ParachuteTrue	= nil
		
-- Create the animation just the way you want it		
local function playAnimationFromServer(MyCharacter, MyAnimation)
	local MyHumanoid = MyCharacter:FindFirstChildOfClass("Humanoid")
	if MyHumanoid then
		local MyAnimator = MyHumanoid:FindFirstChildOfClass("Animator")
		if MyAnimator then
			local MyTrack = MyAnimator:LoadAnimation(MyAnimation)
			MyTrack:Play()
			return MyTrack
		end
	end
end			
		
		
local function onFallingDeath()
    local Base = root.CFrame * Vector3.new(0,-10,0)
    local ray = Ray.new(root.CFrame.p, (Base - root.CFrame.p).unit * 300)
	local part, position = workspace:FindPartOnRay(ray, character, false, true)
	local distance = (root.CFrame.p - position).magnitude		
	print(distance)		
	local MyParachute = character:FindFirstChild("Parachute")		
	if MyParachute == nil then		
	   ParachuteTrue = nil		
	end			
	if MyParachute ~= nil then
		ParachuteTrue = MyParachute		
		local MyBodyVelocity = root:FindFirstChild("BodyVelocity")
		for _, playingTracks in pairs(humanoid:GetPlayingAnimationTracks()) do		
			   playingTracks:Stop()
	    end			
		if MyBodyVelocity then
		   MyBodyVelocity:Destroy()
		end		
		animate.Disabled = false		
	end				
	if distance > EndJump and FallDeath == false and ParachuteTrue == nil then	
        FallDeath = true		
		animate.Disabled = true		
		-- Animation playback	
		playAnimationFromServer(character, animation)	
		-- It makes the downward movement slow		
		local bodyvelocity = Instance.new("BodyVelocity")
        bodyvelocity.maxForce = Vector3.new(0, 99999, 0)
	    bodyvelocity.P = 1250
	    bodyvelocity.velocity = Vector3.new(0,-10,0)
	    bodyvelocity.Parent = root	
	end			
end	
		
		
humanoid.StateChanged:Connect(function(oldState, newState)
	if newState ~= Enum.HumanoidStateType.Freefall then		
		if FallDeath == true then	
		    FallDeath = false		
            for _, playingTracks in pairs(humanoid:GetPlayingAnimationTracks()) do		
			   playingTracks:Stop()
	        end		
			local MyBodyVelocity = root:FindFirstChild("BodyVelocity")
		    if MyBodyVelocity then
		       MyBodyVelocity:Destroy()
		    end
			animate.Disabled = false	
			humanoid:UnequipTools()		
			if ParachuteTrue == nil then		
			humanoid.Health = 0		
			end			
		end			
	end
end)
		

humanoid.FreeFalling:connect(function(onFreeFall)
    if onFreeFall == true then
	   heartbeat = game:GetService("RunService").Heartbeat:Connect(onFallingDeath)
	end			
	if onFreeFall == false then	
	   heartbeat:Disconnect()		
	   heartbeat = nil		
	end			
end)
		
		
end)
end)

If it doesn’t work well tell me about the problem

I wish you good luck in what you do

3 Likes

Also, what do you mean by you did not change the default animation. If I remeber correctly, in the last reply you said you changed the default fall animation to the free fall animation. One more thing, if I use a property signal changed function, would I check if the Movement Direction is 0,0,0. If it is then I would play the free fall animation, if not then the diving animation, correct?

Thank you for the help. Unfortunatly this is not what I am looking for, but I believe this can be a use for my project in the future. Thanks!

2 Likes

Exactly (on the movedir question). On the animation question, I don’t change the defaults, I just use ‘Action’ priority animations which take priority over the defaults. I did not have to change them.

Ah, alright. Thank You so much for your help. I have successfully achieved what I have been looking for: https://gyazo.com/3da7dec699731cfcc7de179def2a81b0

2 Likes

Looks great. I like that animation.

1 Like

Thanks! I still need the diving animation because my recent animator took my robux and dipped me and the animation basically looks like a statue with no movement. Also keep up the great work on your game! Is really good.

1 Like

Hey there, this isnt very related fo the topic I asked but do you know how I can make the character tilt only on the y axis according to their camera’s movement? Is basically shift lock but on Y axis only.

Try to explain more

I do not speak English

Write separate sentences, translation will be better

1 Like

He means how can you make the player rotate around the y axis (as a pole dancer in a sense) while also being always facing away from the camera. I told him he can use the cross difference of the two vectors but oh “that ways too complex” lol

2 Likes