(Feature Request) Animation Track method to get time of Keyframe Marker

I am trying to get the time an Animation Event occurs relative to the start of the Animation Track.

I noticed that I skip over Animation Events when I set an Animation Track’s time position to after the Animation Event. So to determine if I skipped an event, I need the event’s time. I looked at the documentation https://create.roblox.com/docs/reference/engine/classes/AnimationTrack#functions and there is not method to obtain the time. I did notice that there is a method for Keyframes (GetTimeOfKeyframe()) but given that Animation Events are a proper feature (They are editable in the Roblox animation editor), I do not want to resort to using Keyframes.

As such, I am making a feature request here for a GetTimeOfKeyframeMarker() method for Animation Tracks. I’d like to hear what people say about this. And yes I’m aware this is not posted in the Feature Request category. It’s just that this is a feature I am really looking for and the Feature Request category is not open to me.

8 Likes

Big support for this. I’m working on a melee system where I’m tweening a progress bar GUI for each attack, and I want the length of this progress bar to accurately reflect the end of the attack, and not the end of the animation as a whole (which extends longer to include a recovery phase in the animation). Unfortunately markers are incredibly limited and I can’t think of a way to achieve what I’m trying to do without pre-compiling or using some hacky method.

If you want to get this seen, then send it as a message to @ Bug-Support (no space). It will take a few days, but if it’s valid it will get posted to the appropriate feature request forum. And make sure you lead the title off with Feature Request: (Engine).

1 Like

Thank you for the reply, I appreciate the support. I will go send this to @ Bug-Support

Why is this not a thing yet… I have to resort to changing keyframe names of an animation just for this functionality. It’s like I can’t use just keyframe names for scheduling events to happen during an animation and I can’t just use markers because they both have annoying inconveniences.


We have: AnimationTrack:GetTimeOfKeyframe(keyframeName)

We need: AnimationTrack:GetTimeOfMarker(markerName)


So simple.

Pease make animation markers better by adding this functionality.

5 Likes

I agree, There is no reason to ever fetch the time of a keyframe name if there is no event associated. I cannot think of a single use-case for naming keyframes that don’t trigger events. However knowing the difference between the start of the animation and when the event occurs is extremely helpful.

If anyone else needs to get a time of a specific animation event marker you can use this.
Apparently SequenceProvider is Deprecated but this worked for me. (at least for now)

local SequenceProvider = game:GetService("KeyframeSequenceProvider")
local function GetAnimationEventTime(AnimationID, EventName)
	local AtTimes = {}
	local Seq = SequenceProvider:GetKeyframeSequenceAsync(AnimationID)
        Seq.Parent = game.ServeStorage -- Idk why but sometimes doesnt populate without
        task.delay(0, function() Seq:Destroy() end) -- Keep if ref many times?

	for frameNum, keyframe in pairs(Seq:GetChildren())do -- for every keyframe
		for _, child in pairs(keyframe:GetChildren())do -- find any markers
			if child:IsA("KeyframeMarker") then
				-- child.Name is the Name of the Marker that you set!
				if child.Name == EventName then
					table.insert(AtTimes, keyframe.Time)
				end
			end
		end
	end
	
	if not next(AtTimes) then return end
	-- Will Return one time stamp if one event or a table if multiple.
	return #AtTimes == 1 and AtTimes[1] or AtTimes
end

local T = GetAnimationEventTime("rbxassetid://00000000","MarkerName")
print('Event will fire at', T)

4 Likes

That’s handy. Thanks for the response.

Of course official support would be ideal, but this will work for now.

Here is the link of the Engine Feature Request post.

1 Like

Thanks! I would say my solution above is a very very bad way of doing it in a live server. Its slow and can fail. it is handy if you want to run all event based animations through this to get the data and set an attribute on the animation or something like that. or set up a module cache that can be read from.