How do I smooth out this animation + teleport?

Im making a pallet dropping and vaulting system the animation and teleporting work fine individually but they aren’t working well together

heres a video showing my issue

at first i thought the issue had to do with how I was teleporting the player after the animation ended which caused the weird character floating so I tried adding a keyframe event to teleport a few frames before the animation completed but that didnt work out. heres my code

local function onPalletVault(player : Player, pallet : Model)
	local char = player.Character
	local hum = char.Humanoid

	Remotes.Controls:FireClient(player, false)
	pallet.slowVault.CanCollide = false
	
	local lookAt = CFrame.lookAt(char.HumanoidRootPart.Position, pallet.palletDropHitBox.Position)
	local side, newCf = closerCFrame("smaller", pallet:GetAttribute("Left"), pallet:GetAttribute("Right"), char:GetPivot())
	-- Code below is supposed to force the character to face the pallet before vaulting works on its own but with the animation and teleporting decides not to work will fix this later
	player.Character.HumanoidRootPart.CFrame = newCf
	char:PivotTo(lookAt)
	-- Gets the side and CFrame of the side
	local sideToTeleport, cFrametoTeleport = closerCFrame("bigger", pallet:GetAttribute("Left"), pallet:GetAttribute("Right"), char:GetPivot())
	local track = hum:LoadAnimation(palletVaultAnim:FindFirstChild(sideToTeleport))
	track:Play()
	track:GetMarkerReachedSignal("canShockStart"):Connect(function()
		player:SetAttribute("canShock", true)
	end)
	track:GetMarkerReachedSignal("canShockEnd"):Connect(function()

		player:SetAttribute("canShock", false)
	end)

	track:GetMarkerReachedSignal("dismount"):Connect(function()
		player.Character.HumanoidRootPart.CFrame = cFrametoTeleport
		Remotes.Controls:FireClient(player, true)
	end)
end

i was using PivotTo to teleport the player but it didn’t want to teleport in the right places for some reason
heres a video showing what happens when I use PivotTo instead of player.Character.HumanoidRootPart.CFrame = cFrametoTeleport

might be related not sure any help is greatly appreciated

3 Likes

Hey there. In your original code, can you try setting the player’s position when the track ends, as opposed to the dismount keyframe event?

1 Like

thats what I was doing before but it was still causing this weird character floating thing

i was using track.stopped:wait() before teleporting the player

2 Likes

Interesting. Do you think you could provide a quick video, just so I can get a better understanding of the issue it caused? Thanks.

2 Likes

the issue should be shown in the vid i uploaded


basically the character is like floating after the animation ends which i dont know why is happening

First off, you can user either tweens or smoothdamping to make teleporting the player to the correct position of the pallet smooth.

To fix the vaulting animation, you can try to either instantly teleport the player to the other side of the pallet then play the animation which will have to be adjusted so the player appears to be vaulting it smoothly rather than jolting.

Or you can do what I did with my old dbd game of which I just tweened the players hrp cframe to the other side of the pallet. The former method would be more performant so you should probably do that.

Also omg pls dont do animations on the server

3 Likes

No, like when you did it after the animation ended.

1 Like

super late response i know sorry

this sounds like it could work but when would I play the tween? before or after because it doesnt become smooth since the code runs in order from playing the animation before tweening or tweening before the animationis there someway I have to figure out to make it run parallel with the animation?

i forgot animations replicate on the server but wouldn’t I have to fire a remote for every keyframe event?

I still want my players to be hit while their vaulting tho

1 Like

I tried adding this in which i think should teleport my player when the track stops

track.Stopped:Connect(function()
		player.Character.HumanoidRootPart.CFrame = cFrametoTeleport
		Remotes.Controls:FireClient(player, true)
	end)

but I still have the character floating issue

1 Like

ok after looking online again i found this post

basically i just need to do the teleporting and animations on the client and it works fine. i will have to use remotes quite a lot which I dont like but its the only way

1 Like

wait actually it only worked for the window vaulting I was working on the side but not the pallet one :pensive_face:

1 Like

have you tried using root motion? this module might help RootMotion module | Animate the HumanoidRootPart with ease! | Simple | No conversion needed

3 Likes

When the dismount keyyframe is reached, try stopping the anim but put the number “0” on the parethensis. Like this

animnamehere:Stop(0)

1 Like

this solved the weird character floating thing but I teleports the character a little bit farther for some reason ill try out the rootmotion module since thats exactly what i need

3 Likes

Ok!! No problem, i tried to help :slight_smile:

1 Like

actually it hasnt gone away entirely, the floating just becomes much quicker like a teleport, any ideas why?

1 Like

That’s because when an animation stops, it already has a fade time (which is the number in the stop solution i gave you) if you put stop right before the animation ends, it ends that animation without any fade time. if you don’t put it, it’ll probably cause that floating issue you had earlier. (Or you still have)

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.