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
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.
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:
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)
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?
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.
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.
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.
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